Here's a preview from my zine, Bite Size Command Line!! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!
read the transcript!
### head shows the first you 10 lines of a file.
if you pipe a program’s output to head, the program will stop after printing 10 lines (it gets sent SIG PIPE)
tail
tail shows the last 10 lines!
tail -f FILE
will follow:
print any new lines added to the end of FILE. Super useful for log files!
-n NUM
-n NUM (either head or tail) will change the # lines shown
NUM can also be negative. Example: $ head -n 5 file.txt
will print all lines except the last 5
-C NUM
show the first /last NUM bytes of the file
$ head -c 1k
will show the first 1024 bytes
tail –retry
keep trying to open file if it’s inaccesible
tail –pid PID
stop when process PID stops running (with -f
)
tail –follow-name
Usually tail -f
will follow a file descriptor.
tail --follow-name FILENAME
will keep following the same file name, even if the file descriptor changes
Saturday Morning Comics!
Want another comic like this in your email every Saturday? Sign up here!