File Viewing & Editing
Command
Description
Example
cat
Concatenate and display file contents.
cat file.txt → Displays the content of file.txt.
more/less
View file contents one page at a time.
less file.txt → Displays file.txt one page at a time.
nano/vim/emacs
Text editors for file editing.
nano file.txt → Opens file.txt in the Nano editor.
head
Display the beginning of a file.
head -n 5 file.txt → Displays the first 5 lines of file.txt.
tail
Display the end of a file.
tail -n 5 file.txt → Displays the last 5 lines of file.txt.
wc
Count lines, words, and characters in a file.
wc file.txt → Outputs the line, word, and character counts of file.txt.
sed
Stream editor for text manipulation.
sed 's/old/new/g' file.txt → Replaces "old" with "new" in file.txt.
Last updated