Question

In: Computer Science

Linux Directories, File Properties, and the File System in C Code your version of mv command...

Linux Directories, File Properties, and the File System in C

Code your version of mv command in C

  1. The mv command is more than just a wrapper around the rename system call. Write a version of mv that accepts two argument. The first argument must be the name of a file, and the second argument may be the name of a file or the name of a directory. If the destination is the name of a directory, then mv moves the file into that directory. Otherwise mv rename the file if possible.
  2. Add comments to code.

Solutions

Expert Solution

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.


Related Solutions

Linux Directories, File Properties, and the File System in C Your version of find command Try...
Linux Directories, File Properties, and the File System in C Your version of find command Try running the find command in the shell and observe the output. Try it in different folders to make sure you understand what it prints out. $ find Write your version of the find command and add comments.
Linux Directories, File Properties, and the File System in C Understanding Unix/Linux Programming Your version of...
Linux Directories, File Properties, and the File System in C Understanding Unix/Linux Programming Your version of mv command The mv command is more than just a wrapper around the rename system call. Write a version of mv that accepts two argument. The first argument must be the name of a file, and the second argument may be the name of a file or the name of a directory. If the destination is the name of a directory, then mv moves...
Systems Programming - File Operations Create your version of the tail command in Linux using C...
Systems Programming - File Operations Create your version of the tail command in Linux using C The lseek system call allows you to move the current position anywhere in a file. The call lseek(fd, 0, SEEK_END) moves the current position to the end of the file. The tail command displays the last ten liens of a file. Try it. tail has to move, not to the end of the file, but to a spot ten lines before the end of...
Systems Programming in Linux using C Remake the version of the ls -ialR command in C.....
Systems Programming in Linux using C Remake the version of the ls -ialR command in C.. In this version of ls, you must also consider symbolic file types. Make sure you have file header comments and function header comments. Also, write inline comments whenever necessary.
In the Linux file system, the majority of the file system code exists in the kernel....
In the Linux file system, the majority of the file system code exists in the kernel. research the anatomy of the Linux file system, then discuss the effectiveness or ineffectiveness of this type of architecture. In addition, explain why you feel the way you do and provide support
For Linux: Write a command to append the top 20 lines of the file seq.fasta to...
For Linux: Write a command to append the top 20 lines of the file seq.fasta to a second file named combined.seq.
Using Linux in VirtualBox To display your system date: Type date in the command line, and...
Using Linux in VirtualBox To display your system date: Type date in the command line, and press Enter. What do you see?                                            You might see the abbreviation EDT (Eastern Daylight Time) instead of EST (Eastern Standard Time), or another time zone abbreviation, such as MDT (Mountain Daylight Time) or CST (Central Standard Time). Notice also that UNIX/Linux uses a 24-hour clock. Type Date in the command line, and press Enter. What error do you see?                                    The system error...
Ubuntu Linux HW5: text processing; scripting 1. Write a Linux command to rewrite the /var/passwd file...
Ubuntu Linux HW5: text processing; scripting 1. Write a Linux command to rewrite the /var/passwd file to have a tab for each delimiter ':'. Hint: use tr 2. Write a Linux command to extract the user names and sort them. Hint: use cut 3. Write a for loop to to display a time table, e.g., 17 x 1 = 17; 17 x 2 = 34; etc., as follows: 17 x 1 = 17 17 x 2 = 34 17 x...
Introduction Write in C++ at the Linux command line a program that is the same as...
Introduction Write in C++ at the Linux command line a program that is the same as the previous collection app project but now uses a class to store the items and also can save the items to a file that can be read back into the array by the user when the program is re-started. You can use your project 1 submission as a starting point or you can do something new as long as it meets the listed requirements....
Ubuntu Linux HW2: 1. Give one line of the Linux command to see your (your login...
Ubuntu Linux HW2: 1. Give one line of the Linux command to see your (your login ID) credential data from the passwd file. Use a pipe and grep command. 2. Give one line of the Linux command to calculate the following and save it in the hex to a file calcOut. Use bc and <<<. 3+2*4 Submit Screenshots HW3: Permission Show the result clearly after each of the following commands are executed. 1. Create a subdirectory, “HW3”. Write the Linux...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT