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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file with blank lines embedded, want to remove them

Status
Not open for further replies.

confuseddddd

Programmer
May 22, 2003
53
US
Have an input file we are reading where blanks lines exist within a record grouping and created a nawk script to read the input and then build separate output files based on user....Want to not have blank lines in file,
how can this be accomplished using nawk??? We currently use a field separator of blank to create the separate user files.

INPUT FILE (just a snippet but have multiple rows and sometimes all detail rows exist and sometimes do not)
HEAD USER


DET1


DET2

DET3

END


WANT OUTPUT TO BE:
HEAD
DET1
DET2
DET3
END



Thanks in advance for the input.




 
Tried the command sed '/^$/d' data.file > output
and did not remove the blank lines that are embedded between each record in the file....

Anyone have any other suggestions????
 
All these suggestions are great; however, I am still unable to remove the spaces that start at the end of the record and go to where the ^M previously existed.
The request is to remove all the spaces from the end of the record including the carriage control.

Any suggestions????
 
Perhaps running od -hc against your file will show what characters you have on the 'blank' lines, then you can construct the sed command accordingly.
HTH

Dickie Bird (:)-)))
 
Try this:
Code:
X=echo "[ \t\r]\c"
sed -e &quot;s!${X}*&quot;'$!!' <InputFile >OutputFile

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top