cat Command: Cat(concatenate) command is very frequently used in Linux. It reads data from the file and gives their content as output. It helps us to create, view, concatenate files.
cat is used to display the contents of file. To do that for the file stu.txt, simply specify the filename as the argument: cat stu.txt
cat is also useful for creating a file. Enter the command cat, followed by the ‘>’ character and the filename ( for ex. abc) and press the key. Enter text messages and then press :
$ cat > abc
This is simple text file.
Cat is used to represent a rudimentary editor.
<control-d>
$_
cat is also used to append the content in to existing file. Example: cat >> abc
Copy the contents of one file to another file using cat command: cat file1 > file2
Rm command: rm stands for remove here. rm command is used to remove objects such as files, directories, symbolic links and so on from the file system like UNIX.
Files can be deleted with rm (remove). The following command deletes the first three chapters of the text.
$ rm chap1 chap2 chap3
$_
You can easily deletes all files in directory by
$ rm *
$_
Options of rm
rm –i: the -i option makes the command 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.
$ rm -i stu.txt
rm: remove regular empty file 'stu.txt'? y
rm –r: With -r(or -R) option rm command performs a tree-walk and will delete all the files and sub-directories recursively of the parent directory.
$ rm -r