1 | # join fileone filetwo |
1 2 3 4 5 | aaaa Jurassic Park bbbb AI cccc The Ring dddd The Mummy eeee Titanic |
1 2 3 4 5 | aaaa Neil 1111 bbbb Steven 2222 cccc Naomi 3333 dddd Brendan 4444 eeee Kate 5555 |
1 2 3 4 5 6 | # join fileone filetwo aaaa Jurassic Park Neil 1111 bbbb AI Steven 2222 cccc The Ring Naomi 3333 dddd The Mummy Brendan 4444 eeee Titanic Kate 5555 |
1 2 3 4 5 6 | aaaa Neil 1111 bbbb Steven 2222 ffff Elisha 6666 cccc Naomi 3333 dddd Brendan 4444 eeee Kate 5555 |
1 2 3 | # join fileone filetwo aaaa Jurassic Park Neil 1111 bbbb AI Steven 2222 |
1 | # join -1 2 -2 3 fileone filetwo |
1 | # join -o 1.2 -o 2.3 fileone filetwo |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # join -1 4 -2 3 -o 1.1 -o 2.1 -o 1.6 -t":" /etc/passwd /etc/group root:root:/root bin:bin:/bin daemon:daemon:/sbin adm:adm:/var/adm lp:lp:/var/spool/lpd nobody:nobody:/ vcsa:vcsa:/dev rpm:rpm:/var/lib/rpm nscd:nscd:/ ident:ident:/home/ident netdump:netdump:/var/crash sshd:sshd:/var/empty/sshd rpc:rpc:/ |
1 | awk '/pattern/ {action}' file |
1 2 3 4 5 6 7 8 9 10 11 12 | # awk -F: '{print $6}' /etc/passwd /root /bin /sbin /var/adm /var/spool/lpd /sbin /sbin /sbin /var/spool/mail /etc/news /var/spool/uucp |
1 2 3 4 5 6 7 8 9 10 11 12 13 | # awk -F: '{print $1,$6}' /etc/passwd root /root bin /bin daemon /sbin adm /var/adm lp /var/spool/lpd sync /sbin shutdown /sbin halt /sbin mail /var/spool/mail news /etc/news uucp /var/spool/uucp operator /root |
1 2 3 4 5 6 7 8 9 10 11 12 13 | # awk -F: '{OFS="-"}{print $1,$6}' /etc/passwd root-/root bin-/bin daemon-/sbin adm-/var/adm lp-/var/spool/lpd sync-/sbin shutdown-/sbin halt-/sbin mail-/var/spool/mail news-/etc/news uucp-/var/spool/uucp operator-/root |
1 2 3 4 5 6 7 8 9 10 11 12 13 | # awk -F: '{OFS="-"}{print $6,$1}' /etc/passwd /root-root /bin-bin /sbin-daemon /var/adm-adm /var/spool/lpd-lp /sbin-sync /sbin-shutdown /sbin-halt /var/spool/mail-mail /etc/news-news /var/spool/uucp-uucp /root-operator |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # head -2 memo In order to better serve the needs of our mass market customers, ABC Publishing is integrating the groups selling to this channel for ABC General Reference and ABC Computer Publishing. This change will allow us to better coordinate our selling and marketing efforts, as well as simplify ABC's relationships with these customers in the areas of customer service, co-op management, and credit and collection. Two national account managers, Ricky Ponting and Greeme Smith, have joined the sales team as a result of these changes. |
1 2 | # head -c 2 memo In tailtail 工具打印每个文件的最末尾部分的内容(默认是 10 行)。如果没有给定文件,它就从标准输入中读入内容,如果给定了文件名就从文件中读入内容。 举例来说,如果我们希望从 memo 文件中提取最后两行内容,命令如下:
我们可以使用 -c 选项指定要显示的字节个数。举例来说,如果我们希望从 memo 文件中读取最后五个字节的内容,可以使用下面的命令:
结束语现在我们已经知道如何使用各种工具从标准 Linux 文件中向外提取数据了。一旦提取出数据之后,这些数据就可以进行查看、打印或重定向到其他文件或数据库中了。了解了如何使用这些有用的工具可以帮助我们减少花费在烦杂任务上的时间,从而能够成为一名效率更高的管理员。 |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |