Execute the following list of basic commands in UNIX:
(i) rm (ii) mv (iii) wc (iv) cp
(1) rm-
The basic syntax of the rm command is as follows:
rm [options] [file(s) or directory(ies)]
Options:
-i (Interactive Deletion):
This option is used to ask the user for confirmation before removing each file, you have to press y for confirm deletion, any other key leaves the file un-deleted.
-f (Force Deletion): rm prompts for confirmation removal if a file is write protected. The -f option overrides this minor protection and removes the file forcefully.
(2) mv-
The basic syntax of the rm command is as follows:
rm [options] [file(s) or directory(ies)]
Options:
-i (Interactive Deletion):
This option is used to ask the user for confirmation before removing each file, you have to press y for confirm deletion, any other key leaves the file un-deleted.
-f (Force Deletion): rm prompts for confirmation removal if a file is write protected. The -f option overrides this minor protection and removes the file forcefully.
(3) cp-
The basic syntax of the cp command is as follows:
cp [options] [source file/directory destination file/directory]
Options:
-i (Interactive Deletion):
This option is used to ask the user for confirmation before coping each file, you have to press y for confirm deletion, any other key leaves the file un-deleted.
-f (Force Deletion): rm prompts for confirmation removal if a file is write protected. The -f option overrides this minor protection and removes the file forcefully.
1. Copy file cmd1.txt in current directory with the name cmd2.txt.
$ cp cmd1.txt cmd2.txt
2. Copy a file cmd1.txt in ‘ankita1’ directory with the same name that is cmd1.txt
$ cp cmd1.txt ankita1/
3. Copy a file cmd1.txt in ‘ankita1’ directory with different name
$ cp cmd1.txt ankita1/cmd2.txt
4. Use -i option of cp command for interactive mode to prompt before overwriting an existing file.
$ cp -i cmd1.txt cmd2.txt
cp: overwrite 'cmd2.txt' ? y
5. Copy multiple files to a specified directory.
$ cp cmd1.txt cmd2.txt khushi1/
6. Copy multiple files using wild card. It copies all files with extension .txt to 'deepika1' directory.
$ cp *.txt deepika1/








0 Comments