From 0dbd4778df687516be47f5239be78e64153f99f7 Mon Sep 17 00:00:00 2001
From: montiag The The tail command is similar to the head command
+ except that it reads the final lines in files rather than the first lines.
+
+
+ head
head
command reads the first few lines of any text given to it as an input
+ and writes them to standard output.
+ If more than one input file is provided, head will return the first ten lines
+ from each file, precede each set of lines by the name of the file and separate
+ each set of lines by one vertical space.
+
+
+ tail
Examples
+
+ head file1.txt
+ head file1.txt file2.txt
+ tail fail1.txt
-n
option can be used followed by an integer indicating the number of lines desired.
+ -n is a very tolerant option, it is not necessary for the integer to directly
+ follow it without a space in between. In fact, the letter n does not
+ even need to be used at all. Just the hyphen and the integer
+ (with no intervening space) are sufficient to tell head how many lines to return.
+ + head -n15 file1.txt
+ head -n 15 file1.txt
+ head -15 file1.txt
+ ls | head
paste
is a Unix command line utility which is used to join files horizontally
+ (parallel merging) by outputting lines consisting of the sequentially corresponding
+ lines of each file specified, separated by tabs, to the standard output.
+ Once involved, paste
will read all its file arguments. For each corresponding line,
+ paste will append the contents of each file at that line to its output along with a tab.
+ When it has completed its operation for the last file, paste
will output a newline
+ character and move on to the next line.
cat
cat
is a standard Unix utility that reads files sequentially, writing them to standard output.
+ The name is derived from its function to concat
enate files.
+ paste file1.txt file2.txt+ +
+ cat fail1.txt fail2.txt
-d
delimiters, which specifies a list of delimiters to be used instead of tabs
+ for separating consecutive values on a single line. Each delimiter is used in turn;
+ when the list has been exhausted, paste begins again at the first delimiter.
+ + paste -d "|" file1.txt file2.txt + paste -d "|," file1.txt file2.txt
-s
, which causes paste to append the data in serial rather than in parallel;
+ that is, in a horizontal rather than vertical fashion.
+ + paste -s file1.txt file2.txt
-u
is one option flag, -u
for unbuffered output,
+ meaning that each byte is written after it has been read.
+ + cat -u file1.txt file2.txt
-n
this option numbers all output lines
+ + cat -n file1.txt + cat -n file1.txt file2.txt