Unix/Linux Go Back    



Awk to remove carriage return from 65th field

Shell Programming and Scripting




Kindly Note - This is a Single User Post by Forum Member Corona688 Regarding:
Awk to remove carriage return from 65th field.
Please Follow The Primary Link Above to View the Full Discussion.

   
Old Unix and Linux 03-22-2012   -   Original Discussion by pinnacle
Corona688's Unix or Linux Image
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 13 December 2017, 10:16 AM EST
Location: Saskatchewan
Posts: 22,546
Thanks: 1,159
Thanked 4,286 Times in 3,955 Posts
Why would carriage returns be wanted in any of the records, unless the entire file is delimited with \r\n ? Whether it is would be good to know.


Code:
awk -F"|" 'NF==65 { sub(/\r/, ""); T=$0; getline; print T $0; next} 1'