Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sed command losing first line of data when "&" present

Status
Not open for further replies.

Snug

MIS
Sep 5, 2001
59
0
0
US
I have a wierd situatiion. My program below is setup to remove blank lines and seperate the data into 3 files, and replace the "\&" with a "&" in the 'Style' name. It does this successfully, however, if there is a "&" present in the data, it will lose the first line of data.

I've even tried it with this line and it didn't work. I still lost the first line of data when a "&" was present. Any advise?

Code:
style=`awk -F"|" 'NR=1 { print $2; exit 0 }' 1$$.2out`

program
Code:
tmpfile1="./"${basefile}.hdr
tmpfile2="./"${basefile}.det
ok_file="./"${basefile}.ok

#--------Get rid of blank lines
sed 's/^		*//g' ${basefile}.html | sed '/^$/d' > 1$$.1out 

sed -e 's/<//g' -e 's/>/|/g' 1$$.1out >1$$.2out

style=`awk -F"|" 'NR=1 { print $2; exit 0 }' 1$$.2out | sed 's/\&amp;/\&/g'`

styledes=`awk -F"|" 'NR=1 { print $3; exit 0 }' 1$$.2out `

echo "$basefile|$location|$style|$styledes|" >$tmpfile1

awk -F"|" 'NR !=1 { print $2 "|" $3 "|" $4 "|" $5 "|" $6 "|" $7 "|" }' 1$$.2out > $tmpfile2

tmpfile1
Code:
WESTRIDGE & KH.WESTRIDGE|2WTC1-WESTRIDGE| 
SB36BUTT|1|789|Cabinets|0|1|

{NONE}|0|0|Cabinets|-1|1.1|

SB36BUTT|1|789|Cabinets|0|2|

{NONE}|0|0|Cabinets|-1|2.1|

SB36BUTT|1|789|Cabinets|0|3|

{NONE}|0|0|Cabinets|-1|3.1|

SB36BUTT|1|789|Cabinets|0|4|

{NONE}|0|0|Cabinets|-1|4.1|

Thank you!
Snug
 
Replace this:
NR=1
with this:
NR==1

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top