Difference between revisions of "Directory Organization Exercise"
| Line 10: | Line 10: | ||
(There are several ways to undertake this task, but this one aims to make use of TAB-COMPLETION keys and HISTORY. This is the streamlined version, '''not''' that one followed during the course, as it does not require the "heavy lifting" tools of "find" and "vim". | (There are several ways to undertake this task, but this one aims to make use of TAB-COMPLETION keys and HISTORY. This is the streamlined version, '''not''' that one followed during the course, as it does not require the "heavy lifting" tools of "find" and "vim". | ||
| + | |||
| + | This exercise uses "shell" for loops, whose parts are spearated by semicolons. Semicolons do not really need an associated space character. They delimit the individual commands. | ||
* <code>cd</code> to ensure we are in our home directory | * <code>cd</code> to ensure we are in our home directory | ||
| Line 19: | Line 21: | ||
* <code>rm allprojs.tar</code>, by which we delete the tar file, because we have extracted all its contents. | * <code>rm allprojs.tar</code>, by which we delete the tar file, because we have extracted all its contents. | ||
* <code>for i in $(ls *.zip); do mkdir ${i%.*}; done</code> by which we create the directories into which we plan to mv the zip files | * <code>for i in $(ls *.zip); do mkdir ${i%.*}; done</code> by which we create the directories into which we plan to mv the zip files | ||
| − | * <code>for i in $(ls -d */); do cd $i; unzip ${i%/*}.zip; | + | * <code>for i in $(ls *.zip); do mv $i ${i%.*}; done</code> by which we move the zip files into their corresponding directories. |
| + | * <code>tree</code> this simple command verfies to us that the files have moved into the the directory they correspond to. | ||
| + | * <code>for i in $(ls -d */); do cd $i; unzip ${i%/*}.zip; rm c${i%/*}.zip; d ..;done</code>, by which we enter each directory in turn and extract the xip file sinde | ||
Revision as of 19:32, 6 October 2016
Aims
Directory organisation has become more necessary, due the multiple intermediate files that Genomics pipelines produce, and the many output files they produce. Which results file corresponds to which sample? To which replicate?
This exercise bundles 16 projects, packed, in their turn, into 16 zip files.
Data taken from the excellent book "Computational Genomics" by Nello Cristianini and Matthew Hahn (ref. http://www.computational-genomics.net).
Commands
(There are several ways to undertake this task, but this one aims to make use of TAB-COMPLETION keys and HISTORY. This is the streamlined version, not that one followed during the course, as it does not require the "heavy lifting" tools of "find" and "vim".
This exercise uses "shell" for loops, whose parts are spearated by semicolons. Semicolons do not really need an associated space character. They delimit the individual commands.
-
cdto ensure we are in our home directory -
cp $TCH/allprojs.tar .to copy the bundle with all the projects to our home page.
-
tar -tf allprojs.tarto look inside the tar ("tape archive" file) which contains all the zip files. -
tar -xf allprojs.tarto extract them all -
lsto make sure they have been extracted. -
rm allprojs.tar, by which we delete the tar file, because we have extracted all its contents. -
for i in $(ls *.zip); do mkdir ${i%.*}; doneby which we create the directories into which we plan to mv the zip files -
for i in $(ls *.zip); do mv $i ${i%.*}; doneby which we move the zip files into their corresponding directories. -
treethis simple command verfies to us that the files have moved into the the directory they correspond to. -
for i in $(ls -d */); do cd $i; unzip ${i%/*}.zip; rm c${i%/*}.zip; d ..;done, by which we enter each directory in turn and extract the xip file sinde