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
watchdog timeout
Application.FileSearch in Office 2007
Set static IP based on current IP address
Simple SQL Query Date Command
SQL to VBA Syntax
How to rotate text 180º w/o using wordart?
Pattern matching in shell script
Please Advise, very urgent issue, Event ID: 8197, Event Source: MSExchangeFBPublish
Windows XP Home SP3 & WinLogon.exe
Rule that forwards attachments to a folder