Substitute newline with tab at designated field separator

Shell Programming and Scripting

Kindly Note - This is a Single User Post by Forum Member yifangt Regarding:
Substitute newline with tab at designated field separator.
Please Follow The Primary Link Above to View the Full Discussion.

Old 04-02-2013
yifangt yifangt is offline VIP Member  
Join Date: Sep 2009
Last Activity: 16 July 2018, 4:28 PM EDT
Location: Saskatchewan, Canada
Posts: 534
Thanks: 352
Thanked 10 Times in 9 Posts
Thanks Hanson!
What's in my mind with tr is: replace "\n" with "\t" if the rows not connected by "\n" and "@" (That's why I wrote, !\n@, which is not a correct syntax, obviously! ). It seems I have to forget this strategy!
Now the "N" is clear in the command. Could you explain what the "1" does? Similar script I saw with awk
# if a line ends with a backslash, append the next line to it 
# (fails if there are multiple lines ending with backslash...)
 awk '/pattern/ {sub(/\n/,"\t"); getline t; print $0 t; next}; 1' infile

Thanks again!

Last edited by yifangt; 04-02-2013 at 11:48 PM.. Reason: improve wording