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
BEST PRACTICES FOR DEPLOYING FTP
Set initial dir of SHBrowseForFolder function
is there any web mail that allows me to send/receive for free (other than gmail ?)
Cannot get Net Install Images to install
In Powershell, need to find way to grab all computer names from a given AD OU
DateTime and Varchar
Auto Empty Recycle Bin?
Use logged in user credentials to login to Terminal Services 2008?
Can't get integrated authentication to work in Exchange FE/BE deployment
Using MS DataGrid in Microsoft Access 2002/2003