Let's look at the
cat command (short for concatenation), which is used for manipulating text files.
There are a number of things cat can do including:
To display the contents of a file, simply place a filename or the path to a file as an argument.
$ cat fileName
file contents will output here.
cat is also used to create a text file. The following command will allow you to type directly into the terminal to the helloWorld.txt file.
$ cat > helloWorld.txt
type in text here.
To quit, press ctrl+d.
To place two or more text files together, simply use the following command:
$ cat file1.txt file2.txt > newFile.txt
To append instead of overwriting, use
>>. Appending will simply add to the end of a file instead of starting a new one.
$ cat >> helloWorld.txt # now type some text here and it will get appended to existing text.
ctrl+d to when done.
cat command has a few options which you may find useful.
The Linux Command Line takes you from your very first terminal keystrokes to writing full programs in Bash, the most popular Linux shell. Along the way you'll learn the timeless skills handed down by generations of gray-bearded, mouse-shunning gurus: file navigation, environment configuration, command chaining, pattern matching with regular expressions, and more.$ Check price
Ever feel achy from sitting crunched up on your computer table? Try lying down with these optical glasses that allow you to work on your laptop while lying flat on your back. This is the perfect solution with those with limited mobility or those who wish to prevent neck cramps and back strains.$ Check price