Since you don't seem to be familiar with the scripts, here is an example.
#!/bin/sh # usage: svn st | x 2 | xargs rm col=$1 shift awk -v col="$col" '{print $col}' "${@--}"
If you save this to ~/bin/x and make sure that ~/bin is in your PATH (now this is what you can and should put in your .bashrc ), you have the shortest possible command to extract column n; x n.
The script must perform the correct error checking and pledge when called with a non-numeric argument or the wrong number of arguments, etc .; but an extension of this major version will be available in block 102.
You might want to extend the script to allow a different column delimiter. Awk by default parses input into fields in a space; to use another delimiter, use -F ':' , where : is the new delimiter. Implementing this as an option for a script makes it a little longer, so I leave this as an exercise for the reader.
Using
For file file :
1 2 3 4 5 6
You can pass it through stdin (using the useless cat just as a placeholder for something more useful);
$ cat file | sh script.sh 2 2 5
Or specify it as a script argument:
$ sh script.sh 2 file 2 5
Here sh script.sh assumes that the script is saved as script.sh in the current directory; if you save it with a more useful name somewhere in your PATH and mark it executable as in the instructions above, use a useful name instead (and not sh ) instead.
tripleee Sep 06 2018-11-11T00: 00Z
source share