? linux_commands cat hello.txt
hi world
hi boysshe is saying hi
hi helloHELLO everyone
? linux_commands paste -s hello.txt
hi world hi boys she is saying hi hi hello HELLO everyone
? linux_commands paste -s -d "#" hello.txt
hi world#hi boys##she is saying hi#hi hello##HELLO everyone
? linux_commands paste -s -d "\n" hello.txt (等同于cat hello.txt)
hi world
hi boysshe is saying hi
hi helloHELLO everyone
? linux_commands cat test1
hello world!oh my god!
你是
ttt
fff
gagds
? linux_commands cat test4
this is test4oh my god
hey man
? linux_commands paste test1 test4
hello world! this is test4oh my god
oh my god! hey man
你是
ttt
fff
gagds
? linux_commands paste -d "#" test1 test4
hello world!#this is test4
#
#oh my god
oh my god!#hey man
你是#
ttt#
fff#
gagds#
? linux_commands cat hello.txt
hi world
hi boysshe is saying hi
hi helloHELLO everyone
? linux_commands tr h o < hello.txt
oi world
oi boyssoe is saying oi
oi oelloHELLO everyone
? linux_commands tr 'hi' 'oh' < hello.txt <=> tr 'h' 'o' < hello.txt | tr 'i' 'h'
oh world
oh boyssoe hs sayhng oh
oh oello (可以看到是對h和i分別替換)HELLO everyone
? linux_commands tr hi hello < hello.txt
he world (只替換了hi->he)
he boysshe es sayeng he
he helloHELLO everyone
? linux_commands tr boys men < hello.txt
hi werld
hi menn (當boys的長度>men,超出的部分以最后一個字母n補充)nhe in naning hi
hi helleHELLO evernene
? linux_commands cat hello.txt
hi world
hi boys
hello boys
HELLO everyone
she is saying hi
hi boys
? linux_commands sort hello.txt
HELLO everyone
hello boys
hi boys
hi boys
hi world
she is saying hi
? linux_commands sort -r hello.txt
she is saying hi
hi world
hi boys
hi boys
hello boys
HELLO everyone
? linux_commands sort -R hello.txt
she is saying hi
hi boys
hi boys
HELLO everyone
hi world
hello boys
sort?--ignore-case [file]: 對文件[file]的所有行忽略大小寫排列
? linux_commands sort --ignore-case hello.txt
hello boys
HELLO everyone
hi boys
hi boys
hi world
she is saying hi
sort -u [file]:對文件[file]的所有行排序,只保留唯一行(去除重復行)
? linux_commands sort -u hello.txt
HELLO everyone
hello boys
hi boys
hi world
she is saying hi
? linux_commands sort -u hello.txt -o hello_sorted.txt
? linux_commands cat hello_sorted.txt
HELLO everyone
hello boys
hi boys
hi world
she is saying hi
? linux_commands sort -c hello_sorted.txt
? linux_commands sort -c hello.txt
sort: hello.txt:2: disorder: hi boys
6. 重復行篩選命令uniq
sort [file] | uniq : 只展示文件[file]中的各行,重復行只展示一次
? linux_commands cat hello.txt
hi world
hi boys
hi world
hello boys
HELLO everyone
hi world
hi boys
? linux_commands sort hello.txt| uniq
HELLO everyone
hello boys
hi boys
hi world
? linux_commands cat hello.txt (最后兩行新加的)
hi world
hi boys
hi world
hello boys
HELLO everyone
hi world
hi boys
oh boys
Hello everyone
? linux_commands sort hello.txt| uniq -i
HELLO everyone
hello boys
hi boys
hi world
? temp ls
input.txt three two
? temp cat input.txt| xargs -I name sh -c 'echo name; mkdir name' (name作為參數傳遞)
aa
bb
cc
? temp ls
aa bb cc input.txt three two