1/24
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Cat Command
This command is used to concatenate or join files.
cat catfile.txt -n
The -n option tells cat to number all output lines.
> operator
used to redirect output to the new standard output.
> > operator
appends to the file exists or else creates it as a new file and writes the data.
head
useful to see a few lines of a file, typically the first few lines.
10 lines
default of head command
head -3 name.txt
Show the first 3 lines of text in name.txt
head -c10 name.txt
Show the first 10 characters of the name.text
tail
used to show the last few lines of a file.
tail -3 name.txt
show the last 3 in the name.txt file
tail -3 name.txt
Displays the last 3 lines of the name.txt
tail -n4 name.txt
Displays the last 4 lines of the name.txt file
tail -c10 name.txt
Displays the last 10 bytes (characters) of the name.txt file
sort
used to sort the contents of the file and display the sorted list on the standard output (screen).
sort name.txt
Sort the file name.txt in ascending
sort -r name.txt
Sort the name.txt file in Descending
WC Command
stands word count is used to find the number of characters, the number of words, and number of lines in a file.
wc -w file1.txt
Counts the number of Words in the file1.txt
wc -c file1.txt
Counts the number of Characters (bytes) in the file1.txt
wc -l file1.txt
Counts the number of Lines in the file1.txt
grep
one of the most powerful commands in Linux. It matches the given pattern with each line of the file and displays all lines that match the pattern.
grep hope lines.txt
Show the lines that has character pattern hope from the lines.txt and verify the output.
grep lie lines.txt
Show the lines that has character pattern character lie from the lines.txt and verify the output.
pr
used to convert a text file for printing.
pr -3 lines.txt
Show the print preview of lines.txt and names.txt in 3 columns respectively.