Artificial intelligent assistant

Printing more than one field Is there a way to print multiple fields with a single line command? I want to print $3 to $NF, I can do it like below: awk -F[:] '{print $3,$4,$5 .... $NF}' Yet it is not doable with large number of fields and it is prone to errors.

The only way I know is to loop over each field:


$ echo "a:b:c:d:e:f:g:h:i" |
awk -F":" '{for(i=3;i<=NF-1;i++){printf "%s ", $i}print $NF}'
c d e f g h i


Alternatively, you could just use `perl`:


$ echo "a:b:c:d:e:f:g:h:i" | perl -F":" -lane 'print "@F[2..$#F]"'
c d e f g h i


Or `cut`:


$ echo "a:b:c:d:e:f:g:h:i" | cut -d: -f3-
c:d:e:f:g:h:i


Or `sed`:


$ echo "a:b:c:d:e:f:g:h:i" | sed 's/\([^:]*:\)\{2\}//'
c:d:e:f:g:h:i

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy f65d905e51e9bd3f17c949ba8d814121