![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| while loops | nymus7 | Shell Programming and Scripting | 4 | 03-31-2006 09:59 AM |
| two loops | big123456 | UNIX for Dummies Questions & Answers | 2 | 10-11-2005 12:08 AM |
| While Loops | vdc | UNIX for Dummies Questions & Answers | 4 | 05-10-2005 05:55 AM |
| Loops | mariner | UNIX for Advanced & Expert Users | 2 | 07-01-2004 04:50 AM |
| loops? | jonas27 | UNIX for Dummies Questions & Answers | 1 | 11-05-2001 11:28 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
While loops and awk
I am trying to make a script that will replace backslashes in a file, but only if the occurance is a pathname. In the file, there are a lot of regular expressions as well, so I'm trying to preserve the integrity of those regular expressions, but convert Windows relative paths. I'm using bash and this is what I've tried:
line="~/path/to/something~ ~\path\to\something~" loop=2 while [ ! "`echo \"$oldline\" | grep '\\\'`" ]; do # see note... oldline="`echo \"$line\" | tr -d '\r' | awk -F \~ '{print $loop}'`" let loop=$loop+2 done Note: I'm using Mac OS X and apparently Darwin doesn't like a simple escaped backslash. I have to escape the escaping backslash to get it to work. Just don't try to match multiple backslashes, 'cause then it's even more crazy. Just a side note... I've tried these variants of the $loop variable in the awk statement: awk -F \~ '{print $loop}' awk -F \~ '{print $$loop}' awk -F \~ '{print \$$loop}' awk -F \~ '{print $\$loop}' awk -F \~ '{print $"$loop"}' Of course, they all lead to the same error - illegal field $loop. Can anyone help me with an alternate way of doing this? |
| Forum Sponsor | ||
|
|
| Tags |
| regex, regular expressions |
| Thread Tools | |
| Display Modes | |
|
|