I present to you a compilation of the most useful Linux commands for File Content Operations
Pipes and I/O redirection
#redirect command output to a new file
command > output_file.txt
#redirect command output to append to a file
command >> output_file.txt
#redirect command input
command < input_file.txt
#redirect standard output and error output to a file:
command &> output_file.txt
#pipe, redirect command1 output as input to command2
command1 | command2
Display file content
#display file content
echo file
#show file content
cat file
#display file content starting from the end
tac file
#display file content scrolling line by line
more file
#display file content scrolling forward or backward
less file
#display the first two lines of a file
head -2 file
#display the last two lines of a file
tail -2 file
#real-time display of the last lines of a file (tracking)
tail -f file
Text manipulation
#convert lowercase to uppercase
echo 'file' | tr '[:lower:]' '[:upper:]'
#delete lines 1 to 5 from a file
sed '3,5d' file
#delete lines 5 to the end of a file
sed '5,$d' file
#delete blank lines
sed '/^$/d' file
#delete blank lines and comments
sed '/ *#/d; /^$/d' file
#replace one string with another
sed 's/string1/string2/g' file
#display only the lines that contain a string
sed -n '/string/p'
To see the complete compilation of Linux commands go to this link: List of Linux commands