Last active
July 21, 2019 06:04
-
-
Save estysdesu/5096717f57b18c6248e695b8982bdae0 to your computer and use it in GitHub Desktop.
[Shell: view and work with file contents] #more #less #cat #head #tail #wc #sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### cat (SHOW ALL FILE CONTENTS) ##### | |
cat <file> # shows all file contents | |
cat <enter>...<ctrl+d> # echos whatever is typed after enter (useful for redirecting stdin) | |
##### less/more (PAGERS) ##### | |
less <file> # more advanced version of `more`; allows vim navigation | |
##### head/tail (PARTIAL CONTENTS) ##### | |
# Normal indexing (GNU/UNIX) | |
head -n 5 <file> # first 5 lines (defaults to 10) == `head -5 <file>` | |
tail -n 3 <file> # last " " " " " == `tail -3 <file>` | |
# Negative indexing (GNU only) | |
head -n -15 <file> # show all but the last 15 lines | |
# Positive indexing (GNU only) | |
tail -n +8 <file> # show all lines after line no. 8 | |
tail -f <file> # follow/show file contents as it grows | |
#### wc (WORD, LINE, BYTE/CHAR COUNT) ##### | |
wc <file-1> <file-2> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment