Need Help Badly: Newbie Here

I have this file:

NPANXX|BILLDATE|DIVCODE|COMID|RAO|LIKECODE|BOSS|SORD|STATECODE|
087001|BP01|H|SWBT| |041|IMR6|IMSR6|AR|
087002|BP03|H|SWBT| |042|IMR6|IMSR6|AR|
087003|BP05|H|SWBT| |043|IMR6|IMSR6|AR|
....
these are the things that i HAve to do:
Insert a new column named �TEST�
All lines starting with 090 should have a value under the 10th column �TEST� set to �CF5857�
LIKECODE (4th column) of all lines starting with 087 should be changes to �PHI�

This looks like homework... You cant have the perople here do your home work.

What you can do, I beleive, is post what you have done and where you are having issues and maybe someone will help you with a portion of the problem.

post your effort

this is what i've done to insert new column but it does not work.
cat hl.dsldryloop | awk -F\|'{print $1"|"$2"|"$3"|"$4"|"$5"|"$6"|"$7"|"$8"|"$9"|TEST|" } ' >file.txt

This worked for me

awk -F \| '{print $1"|"$2"|"$3"|"$4"|"$5"|"$6"|"$7"|"$8"|"$9"|TEST|" } ' hl.dsldryloop 

was missing space. "..awk -F \|'{print.." vs "..awk -F \| '{print.."

sed -e '1s/\|$/\|TEST\|/g' filename this will add the header TEST for first column..

hey guys please don't use cat command when you are going to use commands like grep,awk and sed....

it still doesn't work ..why is tha?

# cat test.txt
NPANXX|BILLDATE|DIVCODE|COMID|RAO|LIKECODE|BOSS|SORD|STATECODE|
087001|BP01|H|SWBT| |041|IMR6|IMSR6|AR|
087002|BP03|H|SWBT| |042|IMR6|IMSR6|AR|
087003|BP05|H|SWBT| |043|IMR6|IMSR6|AR|

#  awk -F \|  '{print $1"|"$2"|"$3"|"$4"|"$5"|"$6"|"$7"|"$8"|"$9"|TEST|" } ' test.txt
NPANXX|BILLDATE|DIVCODE|COMID|RAO|LIKECODE|BOSS|SORD|STATECODE|TEST|
087001|BP01|H|SWBT| |041|IMR6|IMSR6|AR|TEST|
087002|BP03|H|SWBT| |042|IMR6|IMSR6|AR|TEST|
087003|BP05|H|SWBT| |043|IMR6|IMSR6|AR|TEST|

#

what if i want to save it in a new file?

sed -e '1s/\|$/\|TEST\|/g' infilename > outfilename

Thanks. but TEST column should only be added at the first line

hahaha laze arkhei

sed -e ''1s/\|$/\|TEST\|/g' -e 's/^090.*$/&CF5857\|/g' filename > outfile
this will solve your first and second question

thanks vidyarhar85 it works great. Thanks alot.
can you please explain your im quite confuse
thanks alot