Linux Commands
Linux File Commands
1. Touch Command
The touch command is used to create empty files. We can create multiple empty files by executing it once.
Syntax:
- touch <file name>
- touch <file1> <file2> ....
2. Cat Command
The cat command is a multi-purpose utility in the Linux system. It can be used to create a file, display content of the file, copy the content of one file to another file, and more.
Syntax:
- cat [OPTION]... [FILE]..
To create a file, execute it as follows:
- cat > <file name>
- // Enter file content
Press "CTRL+ D" keys to save the file. To display the content of the file, execute it as follows:
cat <file name>
Output:
3. Rm Command
The rm command is used to remove a file.
Syntax:
rm <file name>
Output:
4. Cp Command
The cp command is used to copy a file or directory.
Syntax:
To copy in the same directory:
- cp <existing file name> <new file name>
Output:
5. Mv Command
The mv command is used to move a file or a directory form one location to another location.
Syntax:
- mv <file name> <directory path>
Output:
6. Rename Command
The rename command is used to rename files. It is useful for renaming a large group of files.
Syntax:
- rename 's/old-name/new-name/' files
For example, to convert all the text files into pdf files, execute the below command:
- rename 's/\.txt$/\.pdf/' *.txt
No comments:
Post a Comment