The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #7 (permalink)  
Old 10-10-2008
vikas027 vikas027 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 77
Red face

Quote:
Originally Posted by zaxxon View Post
Not depending on the tab, but any kind of space/blank/tab:

Code:
sed '/^Message Text/ { s/[[:space:]]\{2,\}/ /g }'

Had also problems testing with "+".
Thanks a million zaxxon, your code works as charm.

These are some more options, I got from others. May be helpful to you or others.


Code:
awk -F'Message text:' '{ gsub(/ +/, " ", $2); print $1 "Message text:" $2; }'

and

Code:
# awk -F"Message Text :" '{print $1}' infile > left
# sed -i 's/$/Message Text :/' left
# awk -F"Message Text :" '{print $2}' infile > right
# sed -i 's/  */ /g' right
# paste -d' ' left right > outfile

Thanks again,
VIKAS