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
textbox value from SQL query
ActiveSync Only Works With No SSL Un-checked - 1 Phone Problem
Get a list of users of a database.
logformat to get full URL
DTSToDate Syntax Error?
RUBY - RESULTS TO .TXT FILE
Revoke access on all tables
Optimize and Understand Keywords for Adwords - Recommendations
Launch Acrobat Distiller from an Access 2002 database form
How to set mailbox size limits on a group?