In: Computer Science
Linux Directories, File Properties, and the File System in C
Code your version of mv command in C
mv stands for move. mv is used to move one or more files or directories from one place to another in file system like UNIX. It has two distinct function
Uses of mv command:
It rename a file or folder.
It moves group of files to different directory.
Syntax of mv command
mv [Option] source destination
1)Here is a version of mv command where the first argument is the name of a file, and the second argument is the name which will rename this file.
Syntax
mv argument1 argument2
Command:
Here we use the mv commnad to rename the file named "newfile" to file "orkut"
This command will rename the file and remove the previous name. The contents of teh file remains the same.
As given in the question, this will work only to rename a file.
2)Here is a version of mv command where the first argument is the name of a file, and the second argument is the direcotry which will move this file to the given directory.
Syntax:
mv argument1 /argument2
This will move the file with the name orkut to the folder or directory /home.
The file will no longer exist in the original place and will be move permanently to /home directory.
I have showed you the new location of the file by going to the honme dirctory using cd and using ls to display the list of files in it.
Note that this requires root priviledges so I have used sudo for it.
If you have any doubts, leave a comment below before rating. I'll be happy to assist you further.
Do UPVOTE this as I have put a lot of EFFORT in answering this question. It really helps me.