Friday, August 10, 2012

Remove Carriage Return from string variable

Recently I was tasked with writing some scripts to copy log files from a drop site to a working directory then to unzip them. This was not a very difficult task but I ran into a small issue, how to remove a carriage return from a string variable

How to remove a Carriage Return from a string variable?

     #use the tr command and the octal code for CR
     logs=`echo ${logs} | tr -d '\15'`

No comments:

Post a Comment