Working with Files
The UNIX system gives various tools which enable to work simply with files. Betwen these tools are the commands which enable to create new files, remove files, copy files, move files among directories that examine the contents of the files and many more.
cat
This command can be used for the subsequent purposes:
- To make a new file
- To show the contents of an already existing file
Syntax
cat [ filename]
in the syntax filename is the name of the file to be created or displayed.
The given example displays how to create a new file newfile using the cat command.
# cat > newfile
This is my new file created via cat command
^D
Pressing ctrl-d marks the end of file.
The contents of the file newfile could be viewed as display below.
# cat newfile
This is my new file created via cat command
Note: the difference among two Commands. One is used to make a file and the other to show its contents.
Redirection symbols which are used with the cat command are as follows:
> Used to create a file
>> Without overwriting the information it used to append
< Used to input the file to commands
cat command could be used to display the contents of more than one file through providing the filenames separated via a space.