Practice Questions for Working with Files and Directories
From Software Carpentry
1. After running the following commands, you realize you put the files sucrose.dat and maltose.dat into the wrong folder. They should’ve been placed in the raw folder.
$ ls -F
analyzed/ raw/
$ ls -F analyzed
fructose.dat glucose.dat maltose.dat sucrose.dat
$ cd analyzed
Fill in the blanks to move these files to the raw/ folder
$ mv sucrose.dat maltose.dat ../raw
2. Suppose you created a plain-text file in your current directory to contain a list of the statistical tests you will need to do to analyze your data, and named it: statstics.txt�After creating and saving this file you realize you misspelled the filename! You want to correct the mistake, which of the following commands could you use to do so?
3. What is the output of the closing ls command in the sequence shown below
$ pwd
/Users/Jamie/data
$ ls
proteins.dat
$ mkdir recombined
$ mv proteins.dat recombined/
$ cp recombined/proteins.dat ../proteins-saved.dat
$ ls
4. When run in the molecules directory, which ls command(s) will produce this output?��ethane.pdb methane.pdb
5. How do you go from the first directory structure to the second using the commands below?
$ cp *dataset* backup/datasets
$ cp ____calibration____ backup/calibration
$ cp 2015-___-___ send_to_bob/all_november_files/
$ cp ___ send_to_bob/all_datasets_created_on_a_23rd/
6. You are working on a project and see that your files aren’t very well organized:
$ ls -F
analyzed/ fructose.dat raw/ sucrose.dat
The fructose.dat and sucrose.dat files contain output from your data analysis. What command(s) covered in this lesson does she need to run so that the commands below will produce the output shown?
$ ls -F
analyzed/ raw/
$ ls analyzed
fructose.dat sucrose.dat
7. Which set(s) of commands will make this file directory structure?
$ mkdir 2016-05-20/data
$ mkdir 2016-05-20/data/processed
$ mkdir 2016-05-20/data/raw
$ cd 2016-05-20
$ mkdir data
$ cd data
$ mkdir raw processed
$ mkdir 2016-05-20/data/processed
$ mkdir –p 2016-05-20/data/processed
$ cd 2016-05-20
$ mkdir data
$ mkdir raw processed
Answers (see this page for more detailed explanations)