Microsoft
Software
Hardware
Network
Question : awk shell script parameters
I have a bunch of numbers in a text file
tl@NewWest:~/pas$ head e6
1 491633.998 5457453.139 62.269
2 491632.579 5457455.151 62.410
3 491632.561 5457455.489 62.102
4 491629.344 5457454.188 62.249
...
the command
tl@NewWest:~/pas$ cat e6|awk '{print 11" " $1}'
produces
11 1
11 2
11 3
11 4
11 5
...
which is the required result
Now - when I try the same thing from within a script file
#!/bin/bash
MONPTS_ARRAY='1 2 16'
for MONPT in $MONPTS_ARRAY; do
cat e6|awk '{print $MONPT " "$1}'
done
exit 0
I get
1 491633.998 5457453.139 62.269 1
2 491632.579 5457455.151 62.410 2
3 491632.561 5457455.489 62.102 3
4 491629.344 5457454.188 62.249 4
5 491648.571 5457488.991 62.123 5
...
For some mysterious reason awk wouldn't recognize the $MONPT parameter and substitute it with a whole line of the file
Any ideas how to make this work?
Answer : awk shell script parameters
awk '{print '$MONPT' " "$1}'
Random Solutions
Put INSERT statements or *.SQL scripts in STORED PROCEDURE ?
Sybase - BCP - oracle.
OWA SBS 2003 Not working internally or externally
Out of office assistant not forwarding mail when reply message is blank or empty.
Meta Tag for Sitemap.xml ?
Directory Log Files
Problem of calling Curl by Perl
How can I set up an auto-responder to let senders know that a new address should be used?
Win98se Won't Boot Up, Can Hear Fan, Monitor says "No Signal"
How to increase rules in outlook 2007