Skip to content

bash_tricks

mschechter19 edited this page Sep 26, 2017 · 4 revisions

21.9.2017

  • miller plugin for bash
# convert a csv to a tabular format
mlr --icsv --opprint cat example.csv

# use cut to only show specific fields, call the field by typing the column name!
$ mlr --icsv --opprint cut -f columnname,shape example.csv
  • whenever you want to parse out a section of a header, column name, etc... an effective method is to use sed to find and replace a part of the header with a tab then cut out the new field
sed -e 's/thingtocut/\t/' | cut -fx

# sed -e is for finding and replacing an expression
# \t is for tabular
# cut -fx -> x is for the field you would like to cut
  • LC=all learn about this... it makes characters on your keyboard smaller bites of informationso that job run faster...

26.9.2017

  • process subsitution allows for mulitple process to be inputed in another command, here is an example:
# before variable X and Y are joined, they are sorted by certain columns
# within each <() a process can take place before it is fed into another function
join -1 2 -2 4 -v2 <(sort -k2,2 $X) <(sort -k3,3 $Y)
Clone this wiki locally