Following are the commands used for renaming files in Unix,
1) $mv fileoriginal filerenamed
The above command is used to rename the file with name, 'fileoriginal' to the new name, 'filerenamed'.
2) $mv diroriginal dirrenamed
The above command is used to rename directory.
Showing posts with label Unix Commands for files. Show all posts
Showing posts with label Unix Commands for files. Show all posts
Wednesday, 17 August 2011
Creating files in Unix
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
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
Subscribe to:
Posts (Atom)