cat is a core utility that generates a stream of data from one or more files (ie file descriptor)
It therefore can:
file 1 - line 1
file 1 - line 2
file 2 - line 1
file 2 - line 2
cat file1.txt file2.txt > fileAll.txt
cat fileAll.txt
file 1 - line 1
file 1 - line 2
file 2 - line 1
file 2 - line 2
Output all files with the pgn extension
cat *.pgn
where: *.pgn is a glob pattern
Concatenate the output of file and of standard input
cat f - g
where:
Example:
echo 'Hello World' | tee f g
Without any argument, cat will copy standard input to standard output
cat
Example:
echo 'Hello World' > helloIn.txt
cat < helloIn.txt > helloOut.txt
cat helloOut.txt
Hello World
# create file descriptor 3 to a file (ie an alias)
exec 3<>/tmp/mycat
# cat works but return nothing
cat /tmp/mycat
# Writes to it
echo "Hello" >&3
# Return Hello
cat /tmp/mycat
cd /tmp
# Creates the pipe in the current directory
mkfifo named_pipe
# Reads from the pipe (blocking) until it can read data
cat named_pipe
cd /tmp
# Writes to the pipe (blocking) until the FIFO is emptied
echo "Hi" > named_pipe