Command | Description |
---|---|
cat <filename> | Display File Content |
less <filename> | Display File Content with feature to go up and down. Press q to exit. |
more <filename> | Display File Content in forward/downward direction. |
tail <filename> | Display last 10 lines of a File. Note: tail bydefault display last 10 lines. |
head <filename> | Display first 10 lines of a File. Note: for first 7 lines you can use "head -7 <filename>" |
cat <filename> | tail -5 | Display last 5 lines of a File. Note: here you can mention any number. |
cat <filename> | head -5 | Display first 5 lines of a File. Note: for first 7 lines you can use "cat <filename> | head -7" |
Note: | is used to take the output of previous command to be processed further by next command.
[user1@localhost Folder]$ for i in {1..15} > do > echo "This is file line number $i" >> file1.txt > done [user1@localhost Folder]$ cat file1.txt This is file line number 1 This is file line number 2 This is file line number 3 This is file line number 4 This is file line number 5 This is file line number 6 This is file line number 7 This is file line number 8 This is file line number 9 This is file line number 10 This is file line number 11 This is file line number 12 This is file line number 13 This is file line number 14 This is file line number 15 [user1@localhost Folder]$ tail file1.txt This is file line number 6 This is file line number 7 This is file line number 8 This is file line number 9 This is file line number 10 This is file line number 11 This is file line number 12 This is file line number 13 This is file line number 14 This is file line number 15 [user1@localhost Folder]$ head file1.txt This is file line number 1 This is file line number 2 This is file line number 3 This is file line number 4 This is file line number 5 This is file line number 6 This is file line number 7 This is file line number 8 This is file line number 9 This is file line number 10 [user1@localhost Folder]$ cat file1.txt | tail -5 This is file line number 11 This is file line number 12 This is file line number 13 This is file line number 14 This is file line number 15 [user1@localhost Folder]$ cat file1.txt | head -5 This is file line number 1 This is file line number 2 This is file line number 3 This is file line number 4 This is file line number 5 [user1@localhost Folder]$