awk output separators?

Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2006
Posts: 17
Reputation: rusman is an unknown quantity at this point 
Solved Threads: 0
rusman rusman is offline Offline
Newbie Poster

awk output separators?

 
0
  #1
Jun 20th, 2007
How can i get awk to separate the output with dashes?
A simple awk '{print $1-$2-$3}' does not work.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,450
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 261
Moderator
masijade's Avatar
masijade masijade is online now Online
Nearly a Posting Maven

Re: awk output separators?

 
0
  #2
Jun 21st, 2007
Shell Scripting Syntax (Toggle Plain Text)
  1. awk '{print $1 "-" $2 "-" $3}'
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 54
Reputation: radoulov is an unknown quantity at this point 
Solved Threads: 5
radoulov's Avatar
radoulov radoulov is offline Offline
Junior Poster in Training

Re: awk output separators?

 
0
  #3
Jun 21st, 2007
Shell Scripting Syntax (Toggle Plain Text)
  1. $ echo "a b c"|awk '$1=$1' OFS="-"
  2. a-b-c

Shell Scripting Syntax (Toggle Plain Text)
  1. $ echo "a b c"|awk '{print $1,$3}' OFS="-"
  2. a-c
Last edited by radoulov; Jun 21st, 2007 at 11:01 am. Reason: Addition
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 17
Reputation: rusman is an unknown quantity at this point 
Solved Threads: 0
rusman rusman is offline Offline
Newbie Poster

Re: awk output separators?

 
0
  #4
Jun 21st, 2007
Got it working, thanks very much, as always
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Shell Scripting Forum
Thread Tools Search this Thread



Tag cloud for Shell Scripting
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC