https://swcarpentry.github.io/shell-novice/04-pipefilter.html
$ wc file.pdb
>> 20 156 1158 file.pdb
wc = word count
lines, words, characters (from left to right)
wc -l only shows the number of lines
wc -m characters
wc -w words
$ wc -l *.pdb
>lengths.txt
Redirects the command’s output to a file
$
sort -nlengths.txt > sorted-lengths.txt
-n 없으면 알파벳 순서)-n 20 would get the first 20)❗️ $ sort -n file.txt > file.txt
Don’t redirect to the same file. It might give you incorrect results and/or delete the content.
sort -r = reverse order
echo hello
hello 그대로 프린트
$ echo hello
>testfile01.txt
$ echo hello>>testfile02.txt
$
head -n 3sorted-lengths.txt
$tail -n 2sorted-lengths.txt
$ sort -n lengths.txt
|head -n 1
| (pipe) = Use the output of the left as the input to the right
This has removed the need for the sorted-lengths.txt file.
$ wc -l *.pdb
|sort -n|head -n 1
Multiple pipes can be used.