1 | 2 | 3 | Current Level: 4 | 5 | 6 | 7
mvChange to the writing directory:
cd ~/Desktop/shell-lesson-data/exercise-data/writing
Rename draft.txt inside the thesis folder to quotes.txt:
mv thesis/draft.txt thesis/quotes.txt
Check the result:
ls thesis
Output should show:
quotes.txt
Move quotes.txt out of thesis and into the current folder:
mv thesis/quotes.txt .
Confirm that thesis is now empty:
ls thesis
Output:
(no output)
Try listing the file directly:
ls thesis/quotes.txt
This should return an error:
ls: cannot access 'thesis/quotes.txt': No such file or directory
Verify that quotes.txt is now in the current directory:
ls quotes.txt
mv will overwrite files without asking.To prompt for confirmation before overwriting, use the -i (interactive) option:
mv -i file1.txt file2.txt
Note: these files are not in the lesson data. You do not need to do this part. Just read it and try and guess the answer.
Imagine Jamie has some files she wants to analyze. After running the following commands, Jamie realizes that she put the files sucrose.dat and maltose.dat into the wrong folder. The files should have been placed in the raw folder.
Current structure:
$ ls -F
analyzed/ raw/
$ ls analyzed
fructose.dat glucose.dat maltose.dat sucrose.dat
$ cd analyzed
sucrose.dat and maltose.dat into the raw/ folder:Can you guess the answer?
$ mv sucrose.dat maltose.dat ../raw
mv without the -i option?. symbol help simplify moving files?