OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Strange problems with awk


Post Reply New Thread Subscribe

 
Thread Tools
antonis666

 
Member Since: Aug 22, 2011
Posts: 3
antonis666 is on a distinguished road

antonis666 is offline
Hello all,

I am a developer, and have just got my brand new iMac. I've always used Linux, and the switch has not been particularly hard so far..

However, I have a very simple awk script which I am using as part of an installation procedure, which refuses to work properly. All it does is replace all occurences of a specific string in a text file. The command is:

awk '{ gsub("<OPSPWD>", OPSPATH, $0); print > FILENAME}' OPSPATH=$OPS_PATH $OPS_PATH/somefile.txt

When I run the command, the subtitutions happen correctly but awk places itself in an infinite loop repeating the last 2 lines of the text file. If I use a different output file however (i.e. replace FILENAME with "anotherfile.txt") the commands runs without problems. What is even more strange is that on a couple of other Macs I've had the chance to try this out on the command runs fine.

Has anyone else run into this type of problem before? Does the awk implementation for Mac have any problems in reading and writing back to the same file? Is there a fix? I can't seem to find any info using google on this issue so I decided to register and post here.

I'm using a brand new Intel i5 iMac, OSX v.10.6.8

Thanks very much for any replies,
Antonis
QUOTE Thanks
antonis666

 
Member Since: Aug 22, 2011
Posts: 3
antonis666 is on a distinguished road

antonis666 is offline
*bump* no-one experienced anything similar ?
QUOTE Thanks
chscag

 
chscag's Avatar
 
Member Since: Jan 23, 2008
Location: Fort Worth, Texas
Posts: 32,017
chscag has a reputation beyond reputechscag has a reputation beyond reputechscag has a reputation beyond reputechscag has a reputation beyond reputechscag has a reputation beyond reputechscag has a reputation beyond reputechscag has a reputation beyond reputechscag has a reputation beyond reputechscag has a reputation beyond reputechscag has a reputation beyond reputechscag has a reputation beyond repute
Mac Specs: 21.5" iMac 2.5 GHz i5, iPad 3rd Gen., 3 iPods

chscag is offline
I moved your post to this forum where you may have better luck getting answers to your question. This is where it should have been posted rather than the "Switcher" forum.
QUOTE Thanks
antonis666

 
Member Since: Aug 22, 2011
Posts: 3
antonis666 is on a distinguished road

antonis666 is offline
Thanks!
QUOTE Thanks
i.e.sonderby

 
Member Since: Sep 08, 2011
Posts: 1
i.e.sonderby is on a distinguished road

i.e.sonderby is offline
This MIGHT be a similar problem (I'm a newbie) - same machine: -version 10.6.8

awk <plink.356.assoc '{s += $9} END {print FILENAME,",", s/NR}'

It never prints the filename, but only:
, 0.510662

However, solved it by doing:
awk '{s += $9} END { print FILENAME, s/NR}' plink.356.assoc

Cheers, Ida

Last edited by i.e.sonderby; 09-08-2011 at 10:22 AM.
QUOTE Thanks

Post Reply New Thread Subscribe


« Problems Installing xcode | installing xcode 4 on leopard 10.6.4 »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Strange Microsoft/MSN Messenger connection problems blaine_t OS X - Operating System 1 03-02-2009 08:30 PM
Realtek sound problems, lag problems Starflame Running Windows (or anything else) on your Mac 2 11-08-2008 10:54 AM
iMac + MacBook MacBookPro Internet Connection Problems stevend Internet, Networking, and Wireless 2 10-05-2008 11:19 AM
Problems with leopard an gael cliste OS X - Operating System 2 09-18-2008 09:37 AM
Strange ghost images/display problems njbrubaker Switcher Hangout 3 06-05-2006 12:18 PM

All times are GMT -4. The time now is 10:38 AM.

Powered by vBulletin
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?