🎴 Flashcard Mode

Linux/Unix Shell Scripting Basics

Card1 / 8
Mastered0
Review0
QuestionClick to flip

You are executing the following commands in a shell $ cp ~/myfile.dat /media/mounted/ext/drive1/newmyfile.dat $ cd /media/mounted/ext/drive1 $ mv newmyfile.dat oldmyfile.dat and now you are asked to display the long listing of the file "newmyfile.dat". Which of the following will you use ?

AnswerClick to flip back
A
a,b and c will give correct results.
💡 Explanation:

The commands execute successfully: cp copies ~/myfile.dat to /media/mounted/ext/drive1/newmyfile.dat, cd changes to that directory, mv renames newmyfile.dat to oldmyfile.dat. When asked to display the long listing of 'newmyfile.dat', all three approaches have issues: !cp:2 and !mv:1 are invalid history expansion syntaxes, and the full path references a filename that no longer exists (it was renamed to oldmyfile.dat). Only option E correctly identifies that options A, B, and C will all fail.

Change Mode