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
Replace space in variable with _
Moving VHD to a 2008 Hyper-V Server
Windows searches for PRORET.MSI
sharepoint
Perl script to Copy Files from Mapped Drive to another drive on same Server.
Problem launching Excel from server
CBT Recommendations / VMware
Extremly slow receiving POP3 email Outlook 2007
remote host "128.121.4.11", responded to the SMTP command "rcpt" with 550 5.7.1 Unable to relay
Can you record with inches in a layer size transformation?