From cf0caf5e8eda22990961c45f9bc36a48e5399ce1 Mon Sep 17 00:00:00 2001 From: tasmainawolf <44279746+tasmainawolf@users.noreply.github.com> Date: Sun, 18 Nov 2018 03:48:24 +0800 Subject: [PATCH] Added another usage of cat (#21928) --- guide/english/bash/bash-cat/index.md | 92 +++++++++++++++------------- 1 file changed, 50 insertions(+), 42 deletions(-) diff --git a/guide/english/bash/bash-cat/index.md b/guide/english/bash/bash-cat/index.md index fd70e61c8d..8603f851b9 100644 --- a/guide/english/bash/bash-cat/index.md +++ b/guide/english/bash/bash-cat/index.md @@ -1,42 +1,50 @@ ---- -title: Bash Cat ---- - -## Bash Cat - -`cat` is one of the most frequently used commands in Unix operating systems. - -`cat` is used to read a file sequentially and print it to the standard output. -The name is derived from its function to con**cat**enate files. - -### Usage - -```bash -cat [options] [file_names] -``` - -Most used options: - -* `-b`, number non-blank output lines -* `-n`, number all output lines -* `-s`, squeeze multiple adjacent blank lines -* `-v`, display non-printing characters, except for tabs and the end of line character - -### Example - -Print in terminal the content of file.txt: -```bash -cat file.txt -``` - -Concatenate the content of the two files and display the result in terminal: -```bash -cat file1.txt file2.txt -``` - -**Tip**: Using `cat` on a directory will cause error, so make sure it's a readable file. - -#### More Information: -* Wikipedia: https://en.wikipedia.org/wiki/Cat_(Unix) - - +--- +title: Bash Cat +--- + +## Bash Cat + +`cat` is one of the most frequently used commands in Unix operating systems. + +`cat` is used to read a file sequentially and print it to the standard output. +The name is derived from its function to con**cat**enate files. + +Cat can also be used to create a text file. + +### Usage + +```bash +cat [options] [file_names] +``` + +Most used options: + +* `-b`, number non-blank output lines +* `-n`, number all output lines +* `-s`, squeeze multiple adjacent blank lines +* `-v`, display non-printing characters, except for tabs and the end of line character + +### Example + +Print in terminal the content of file.txt: +```bash +cat file.txt +``` + +Concatenate the content of the two files and display the result in terminal: +```bash +cat file1.txt file2.txt +``` + +**Tip**: Using `cat` on a directory will cause error, so make sure it's a readable file. + +Creating a new text file: +```bash +cat > yourfile.txt +``` +After pressing Enter, the cursor will be placed on the next line. You can start entering your desired text directly into your file. Press Ctrl+D or Ctrl+C to exit the file. + +#### More Information: +* Wikipedia: https://en.wikipedia.org/wiki/Cat_(Unix) + +