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

parse and concatenate fields

Status
Not open for further replies.

alfie002

Technical User
Mar 3, 2004
121
GB
Hello all,

I have a file with the following format of fields on each line of the file.The number of fields is variable and can vary from 2 fields to 6

EG:

field1 field2 field3

I need to be able to read the file, read each line and then concatenate the fields on each line with a "_".

EG

field1_field2_field3

The entries should then be written to a new file.

Help would be appreciated.

Thanks

Alf
 
Why not simply this ?
sed 's! !_!g' /path/to/input > output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top