Linux: Show File Content
By Xah Lee. Date: .
Show file content
cat fname
-
print file content to screen.
cat fname | more
-
show file content by one screenful page at a time.
This is called “paging”.
Type q to exit. Type h for other keys.
Show first few lines or last few lines of a file
head fname
-
View the first few lines of a file. (most useful for big files, e.g. Log file.)
tail fname
-
View the last few lines of a file.
tail -f fname
-
View the last few lines of a growing file, updated continuously. Typically used on log files. Ctrl + c to exit.
Show file type
file fname
-
print what type of file it is. (For example, text, jpg, png, pdf, etc.)
edit a file
vi fname
-
edit a file. Type Escape : q to exit. [see vim Basics]