There are 2 ways to create files in Unix. They are as follows,
1) touch
2) cat
1) touch
Syntax: $touch filecreated
The above command creates an empty file with the name 'filecreated'. This is mainly used when there is a need to create more empty files.
Eg: $touch filecreated1 filecreated2 filecreated3
In the above example, totally 3 empty files will be created in the given names.
2) cat
Syntax: $cat > filecreated
Press Enter, then type lines you want to be in the file 'filecreated'.
Press Ctrl+D for End of Line (EOF).
It saves the file and again it comes into $ mode.
Other usages of cat:
1) $cat filecreated
This command will display the contents of file, 'filecreated'.
2) $cat filecreated1 filecreated2 > filemerged3
The above command will store the contents of 'filecreated1' and 'filecreated2' in the file, 'filemerged3'. The contents of 'filemerged3' is overwritten.
To append the contents to the file, 'filemerged3', use the below command,
$cat filecreated1 filecreated2 >> filemerged3
No comments:
Post a Comment