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: 20 February 2018, 1:38 PM EST
Location: Saskatchewan
Posts: 22,613
Thanks: 1,170
Thanked 4,301 Times in 3,968 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'