Hi,
My input file as follws
$ cat 1.txt
-------
a aa aaa 11
b bb bbb 22
I am able to extract first and last column of a given line as follows.
$ nawk '{print $1}' FS= RS= 1.txt | awk '{ $NF = ""; print }'
a
$ nawk '{print $1}' FS= RS= 1.txt | awk '{ print $NF}'
11
however, the same is not working by using shell script. My script as follows.
$ cat 11.ksh
-----
#!/usr/bin/ksh
for i in 1 2
do
nawk '{print $$i}' FS= RS= 1.txt | awk '{ $NF = ""; print }'
nawk '{print $$i}' FS= RS= 1.txt | awk '{print $NF}'
done
--
I am getting the below error.
--
$ sh 11.ksh
awk: 0602-562 Field $() is not correct.
The input line number is 1. The file is 1.txt.
The source line number is 1.
awk: 0602-562 Field $() is not correct.
The input line number is 1. The file is 1.txt.
The source line number is 1.
awk: 0602-562 Field $() is not correct.
The input line number is 1. The file is 1.txt.
The source line number is 1.
awk: 0602-562 Field $() is not correct.
The input line number is 1. The file is 1.txt.
The source line number is 1.
---
Possibly, the error is because of '$$i' in shell script. Any help to fix this much appreciated.
Thansk in advance.