TP 2.1: Files and directories
Goal: Move inside tree structure.
The purpose of this practice is to put you in situation: You have launched calculations (in work
space) and must organize and store results inside your personal backup space (save
). Fasta files will be stored into data
directory from save
space. Following the same logic, blast files will be stored into blast
directory in save
space.
Reminder
Current state of your directories:
/home/<username>
: configuration files/save/user/<username>
: backup space, empty/work/user/<username>
: working space, files resulting from analysis
Prerequisite¶
Before starting this practice, please type the following command:
cp -r /home/formation/save/tp_unix/data/* ~/work
Create a project directory¶
Question
In you save
space, create a folder called tp_unix
, go in this folder.
Solution
cd /save/user/<username>
mkdir tp_unix
cd tp_unix
You must replace <username>
by your username
Structure the projet¶
Question
Create the sub-directories data
, blast_result
.
Solution
mkdir data
mkdir blast_result
or in one line
mkdir data blast_result
Visualize the content of your working directory¶
Question
List all the files inside the work
directory.
Solution
Many possibilities (not exaustive):
-
by going inside the directory
cd cd work ls
-
by using relative path
ls ../../work/user/<username>
-
by using the absolute path
ls /work/user/<username>
-
by passing by the home directory shortcut.
ls /home/<username>/work
-
the same, but using the shortcut
~
that go to the home directory.ls ~/work
Organize data¶
Question
- Move the files
*.fasta
inside directorytp_unix/data
; check that none exists inwork
directory. - Copy blast result files (
*.blast
) inside directorytp_unix/blast_result
.
Solution
For 1:
cd /home/<username>/work
mv *.fasta ~/save/tp_unix/data
ls
For 2:
cp *.blast ~/save/tp_unix/blast_result
Create symbolic link (shortcut)¶
Question
In order to avoid multiple copies of a file, a good practice is to use symbolic link (shortcut) pointing on this file.
Go in the directory ~/work
and créate a symbolic link that points to the file ~/save/tp_unix/data/ab005233.fasta
.
List in detailled manner the files inside your space work
.
Solution
One solution
cd ~/work
ln -s ~/save/tp_unix/data/ab005233.fasta
ls -l
or an equivalent solution
ln -s ~/save/tp_unix/data/ab005233.fasta ~/work
cd ~/work
ls -l