Command Line Exercises

From wiki
Revision as of 17:56, 12 April 2017 by Rf (talk | contribs)
Jump to: navigation, search

Command-line Exercises

Many of these are so called throwaway one-liners

In each of these examples we show the finished one-liner first, and then proceed to build it up

Extract columns from files held in differenrt subfolders

We shall run a for-loop in the shell environment and execute an awk column-selecting command for a certain file called report.tsv


Finished Command

for i in $(ls -d */); do S=$(echo ${i%/*}); export S; awk '{if(NR!=1){if($19 != ".") {system("./echon.sh $S"); printf "\t%s\t%s\t%s\t%s\t%s\n",$2,$15,$17,$19,$20}}}' ${i}report.tsv;echo;done >a.xls

for-loop over the subfolders