Linux cat command
The Linux cat command is used to display file content. You can also use this to create new files or copy file contents to other files.
Syntax:
Examples:
#1. Display File Content
For example, use the following command to list the content of /etc/passwd
file.
Output:
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
…
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
…
#2. Display Multiple File Content
You can also display the multiple file content in a single command.
#3. Display Line Numbers
Use -n switch to display the line numbers with results of cat command.
#4. Create New File
You can also create files with the cat command. The type command line below (change filename as per yours)
#5. Redirect file content to other files
You can use the redirect operator with the cat command to copy file content to others.
You can also copy multiple file content to other files.
0 Comments
CAN FEEDBACK
Emoji