Summary Linux command list
This command outputs the file contents as standard. "cat" is an abbreviation for "concatenate". Since "concatenate" = "concatenate", it should be It may be more polite to say "concatenate file contents and output as standard" rather than "output file contents as standard".
/home/hoge
$cat target file
option | Description |
---|---|
-n | Output with line numbers |
-b | blank(Blank line)Output with line numbers without |
-s | Output consecutive blank lines as one blank line |
-E | At the end of each line"$"Output with |
-T | Tab"^I"Replace with and output |
Output with line numbers.
Without options
/home/hoge/test
$ cat test.txt
hoge
hogehoge
hogehogehoge
hogehogehogehoge
With the -n option, the output is as follows.
/home/hoge/test
$ cat -n test.txt
1 hoge
2 hogehoge
3
4 hogehogehoge
5
6
7
8 hogehogehogehoge
9
Output with line numbers without blanks.
/home/hoge/test
$ cat -b test.txt
1 hoge
2 hogehoge
3 hogehogehoge
4 hogehogehogehoge
Output consecutive blank lines as one blank line
/home/hoge/test
$ cat -s test.txt
hoge
hogehoge
hogehogehoge
hogehogehogehoge
By the way, if you combine -s and -n ↓
/home/hoge/test
$ cat -ns test.txt
1 hoge
2 hogehoge
3
4 hogehogehoge
5
6 hogehogehogehoge
7
Output with "
/home/hoge/test
$ cat test.txt
hoge$
hogehoge$
$
hogehogehoge$
$
$
$
hogehogehogehoge$
$
Replace tab with "^ I" and output
In the following cases
/home/hoge/test
$ cat ex.txt
hoge
hogehoge
hogehogehoge
↓ It will be like this.
/home/hoge/test
$ cat ex.txt
hoge
^Ihogehoge
^I^Ihogehogehoge
Output by concatenating multiple files. (Original cat)
/home/hoge/test
$ cat hoge.txt
hoge
$ cat hoge2.txt
hogehoge
$ cat hoge3.txt
hogehogehoge
$ cat hoge.txt hoge2.txt hoge3.txt
hoge
hogehoge
hogehogehoge
You can also create a new file that is concatenated.
/home/hoge/test
$ cat hoge.txt
hoge
$ cat hoge2.txt
hogehoge
$ cat hoge3.txt
hogehogehoge
#Create 3 files as superhoge
$ cat hoge.txt hoge2.txt hoge3.txt > superhoge
$ cat superhoge
hoge
hogehoge
hogehogehoge
pwd, mkdir, cd , cat, cp, ls, touch, less, mv, rm, ssh, man, ** Adding at any time **
We undertake various development and construction contracts and mentor work for beginners. If you are interested, please go to ** here **
Recommended Posts