3 ms·
Can it output fields in an order other than their input order? That's the one thing I regularly wish cut could do. I would like the output of the second cut bel
by tzs 6y ago
Can it output fields in an order other than their input order? That's the one thing I regularly wish cut could do. I would like the output of the second cut below to be "3,1", not "1,3".
$ echo "1,2,3,4,5" | cut -d , -f 1,3
1,3
$ echo "1,2,3,4,5" | cut -d , -f 3,1
1,3
- js2 6y agoawk -F, '{print $3","$1}'
- Klasiaster 6y agoYes: $ echo "1,2,3,4,5" | choose -f , 2 0 3 1 $ echo "1,2,3,4,5" | choose -f , 2:0 3 2 1 Note that the indexing starts with 0, "-d" is "-f", and a range is denoted by ":" instead of "-" which is used for indexing from the end.