Difference between revisions of "Command Line Exercises"
Line 11: | Line 11: | ||
== Finished Command == | == 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 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 = | = for-loop over the subfolders = |
Revision as of 16:58, 12 April 2017
Contents
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