6

help required with shell script

view full story
linux-howto

http://www.unix.com – Hi, My input file as follws $ cat 1.txt ------- Code: a aa aaa 11 b bb bbb 22 I am able to extract first and last column of a given line as follows. Code: $ nawk '{print $1}' FS= RS= 1.txt | awk '{ $NF = ""; print }' a Code: $ 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 ----- Code: #!/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 -- (HowTos)