madasafish
Technical User
example:
Note: The 1 to 9 string shown here could easily be
1 to 900
echo "1 2 3 4 5 6 7 8 9" |nawk '{print $2,$(NF-1)}'
gives me
2 8
What I would like is:
2 3 4 5 6 7 8
Any help appreciated.
Madasafish2
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
awk '{for(i=2;i<NF;i++)printf$i (i<NF-1?FS:RS)}' /input/file
[gray]# or how aigles likes it[/gray]
awk '{for(i=2;i<NF;i++)printf"%s%s",$i,i<NF-1?FS:RS}' /input/file
[gray]# or if you do not care about leading and trailing spaces[/gray]
awk '{$1=$NF=""}1' /input/file
[gray]# or if you do not want extra spaces[/gray]
awk '{$1=$NF="";sub("^"FS,"");sub(FS"$","")}1' /input/file