Linux File Commands - www.studyandupdates.com

Sunday

Linux File Commands

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:

  1. touch <file name>  
  2. touch <file1>  <file2> .... 

Output:



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:

  1. cat [OPTION]... [FILE]..  


To create a file, execute it as follows:

  1. cat > <file name>  
  2. // 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:

  1. 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:

  1. 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:

  1. rename 's/old-name/new-name/' files  

For example, to convert all the text files into pdf files, execute the below command:

  1. rename 's/\.txt$/\.pdf/' *.txt  


Output:











No comments:

Post a Comment

Popular Posts