cat

What is cat?

cat is a tool that is implemented in every distribution of Linux, the main purpose of cat is to read files and echo that to the shell environment. The directory we are currently in is : /etc

How to use cat

Be sure to understand the pipecommand first

# syntax
cat <FILE>

##### read a file
cat passwd # success, file is read
cat /etc/passwd # success, file is read
cat ./passwd # success, file is read

##### try to read a file (failure)
cat /passwd # failure, file will not be read since the directory root is specified first (/)
cat etc/passwd # failure, file will not be read since the directory root is not specified first (/)

##### read a file with extra options
cat -n /etc/passwd # print the file with line indexation on the left side
cat /etc/passwd | more # echo the file, and output this to the tool "more" so it can be read more easily

Last updated