in Operating System
2 votes
2 votes

Which of the following commands or sequences of commands will rename a file x to file y in a Unix system ?

  1. mv y, x
  2. mv x, y
  3. cp y, x (rm x)
  4. cp x, y (rm x)
  1. II and III
  2. II and IV
  3. I and III
  4. II only
in Operating System

2 Answers

5 votes
5 votes
Best answer

ans is B


The mv command is used to move or rename files.

mv renames file SOURCE to DEST, or moves the SOURCE file (or files) to DIRECTORY.

cp = copies files from one location to another

rm : deletes a file without confirmation (by default).

Therefore cp x, y // will copy x to y

ans rm x // will deletes the file 

selected by

1 comment

from your statements,

cp x,y(rm x)

above command will copies the contents of file x to file y. and deletes file x.

so,now file y will contains   previous file y content + file x content.


i think option D( II only) would be more appropraiate
–3 votes
–3 votes
ans c)

1 comment

how is it option C?

mv source destination

cp source destination

hence option B should be ans.

Related questions