If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > a simple 'awk' doesn't work?!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-07-07, 16:13
MonkeyMM MonkeyMM is offline
Registered User
 
Join Date: Jul 2007
Posts: 2
a simple 'awk' doesn't work?!



just want to replace the space and "go" in the sample file to No space and "GO", so I think something like follows would work, but not... couldn't figure out what's wrong... please help!

awk '{ sub(" go", "GO"); print}' test2.txt
awk: syntax error near line 1
awk: illegal statement near line 1
Reply With Quote
  #2 (permalink)  
Old 11-08-07, 04:17
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
You'd do better just using the sed command

Code:
cat test2.txt | sed 's/ go/GO/'
Mike
Reply With Quote
  #3 (permalink)  
Old 11-09-07, 15:39
radoulov radoulov is offline
Registered User
 
Join Date: May 2007
Location: Milano, Italy
Posts: 22
On Solaris [/usr]/bin/awk is too old and broken.
Use nawk or /usr/xpg4/bin/awk.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On