\
key on most keyboards). What this operator does is feed the output from the program on the left as input to the program on the right.>
in order to redirect output stream (mostly to a file)."|" vs ">"The difference between > (redirection operator) and | (pipeline operator) is that while the > connects a command with a file, the | connects the output of a command with another command.
"-" A hyphen (used alone) generally signifies that input will be taken from stdin as opposed to a named file:1[[email protected] ~]# cat file1 - file22This is 1st line of file1.34This is 3rd line of file1.5THIS IS MY INPUT6Ctrl+d7This is 1st line of file2.8This is 2nd line of file2.910This is 4th line of file2.Copied!
tac
is a command under Linux, try it for yourself.-t
option we can select output format and display it. (Traditional format specifications may be intermixed):-A
Option displays the contents of input in different format by concatenation some special character (offsets).-An
Option displays the contents of input in character format but with no offset information:-a
option convert all blanks, instead of just initial blanks:unexpand only convert double spaces and more to tab, it doesn't convert single spaces!
-s
option to squeeze repetition of characters :-d
option can be used to delete specified characters :-c
option For example, to remove all characters except digits, you can use the following.:--column
defines number of columns created in the output.-l
specifies page length (default is 66 lines).As usual, refer to the man page for details.-n Format
Uses the value of the Format variable as the line numbering format. Recognized formats are:By default nl skip over blank lines and does not give a number to them, use -ba switch to assign them numbers.
cat -n filename
does the same thing that nl
command do. -n
option sort the contents numerically. Also we can sort a file base on "n"
th column with -k
n option:-r
to reverse the result of comparisons. Other options of sort command:sort 1.txt 2.txt
-D
to see all duplicated lines. other options from uniq --help :-l linenumber
-b bytes
cat x* > orginalfile
.head --help
:-e
or -E
option. less -e /var/log/auth.log
or less -E /var/log/auth.log
less +/sshd /var/log/auth.log
less +F /var/log/messages
Ctrl+c
keys.Shift+f
key stroke while matching a keyword.less vs moreless command is similar to more, he main difference between more and less is that less command is faster because it does not load the entire file at once and allows navigation though file using page up/down keys.Whether you decide to use more or less, which is a personal choice, remember that less is more with more features.
When usingjoin
, the input files must be sorted by the join field ONLY, otherwise you may see the warning
join -1 2 -2 2 file1 file2
uses second field of each line. join command options: