文本处理命令1
2013-03-31 00:00
190 查看
shuf 随机显示几行
shuf -n <num> file
split 分割文件
split -<行数> -b <字节> -C <字节> file <输出文件名>
csplit 还是分割文件
csplit file 1 2 3 file分成4分 0 1 2 3-10
paste 列合并
cut 列分割
uniq相同行只显示一行
sort 排序
---------------------------------------------------------------------------------------------------------------------------------------
shuf -n <num> file
[buku@localhost ~]$ ps aux | shuf -n 10 root 1493 0.0 0.0 0 0 ? S< Mar28 0:00 [fcoethread/0] root 2280 0.0 0.0 5568 304 ? S Mar28 0:00 udisks-daemon: not polling any devices root 8248 0.0 0.0 2968 1068 ? S< Mar28 0:00 /sbin/udevd -d buku 2290 0.0 0.5 179556 9444 ? Sl Mar28 0:01 gnome-volume-control-applet buku 9951 0.0 0.0 5260 1532 pts/1 Ss Mar28 0:00 bash root 1967 0.0 0.0 2008 408 tty2 Ss+ Mar28 0:00 /sbin/mingetty /dev/tty2 root 1553 0.0 0.0 7308 360 ? Ss Mar28 0:00 /usr/sbin/wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -B -u -f /var/log/wpa_supplicant.log -P /var/run/wpa_supplicant.pid ntp 1839 0.0 0.0 5140 1132 ? Ss Mar28 0:00 ntpd -u ntp:ntp -p /var/run/ntpd.pid -g 68 1679 0.0 0.1 6812 2040 ? Ss Mar28 0:02 hald buku 2324 0.0 0.7 67868 13764 ? S Mar28 0:09 /usr/libexec/clock-applet --oaf-activate-iid=OAFIID:GNOME_ClockApplet_Factory --oaf-ior-fd=28
split 分割文件
split -<行数> -b <字节> -C <字节> file <输出文件名>
[buku@localhost ~]$ ps aux | shuf -n 10 > netstat [buku@localhost ~]$ split -4 netstat xx [buku@localhost ~]$ ls xx* xxaa xxab xxac [buku@localhost ~]$ cat xxaa gdm 2079 0.0 0.0 3628 404 ? S Mar28 0:00 /usr/bin/dbus-launch --exit-with-session buku 9951 0.0 0.0 5260 1532 pts/1 Ss Mar28 0:00 bash root 31 0.0 0.0 0 0 ? S Mar28 0:00 [crypto/0] buku 2202 0.0 0.0 3628 404 ? S Mar28 0:00 dbus-launch --sh-syntax --exit-with-session
csplit 还是分割文件
csplit file 1 2 3 file分成4分 0 1 2 3-10
[buku@localhost ~]$ csplit -f yy netstat 1 2 3 0 106 70 787 [buku@localhost ~]$ ls yy* yy00 yy01 yy02 yy03
paste 列合并
[buku@localhost ~]$ cat <<EOF> file1 > 1 > 2 > 3 > EOF [buku@localhost ~]$ cat file1 1 2 3 [buku@localhost ~]$ cat <<EOF> file2 > 4 > 5 > 6 > EOF [buku@localhost ~]$ paste -d @ file1 file2 1@4 2@5 3@6
cut 列分割
[buku@localhost ~]$ paste -d @ file1 file2 > file3 [buku@localhost ~]$ cut -d '@' -f 2 file3 4 5 6 [buku@localhost ~]$ cut -d '@' -f 1 file3 1 2 3-d 分割符 -f 显示第几段
uniq相同行只显示一行
[buku@localhost ~]$ cat file1 1 2 3 1 1 2 4 [buku@localhost ~]$ uniq file1 1 2 3 1 2 4
sort 排序
---------------------------------------------------------------------------------------------------------------------------------------
相关文章推荐
- 文本处理命令-三剑客
- 文本处理命令-链接命令
- 文本处理流编辑器sed命令用法
- 常见处理文本的SHELL命令
- shell命令之文本处理
- linux下的文本处理命令sed&awk&grep
- Linux 基础命令(八)—— 文本处理三剑客之sed
- 高级Bash脚本编程指南(27):文本处理命令(三)
- linux sed命令参数及用法详解---linux 利用script来处理文本文
- RHCE033复习(一)---常用文本处理命令、打包命令、磁盘文件系统处理命令
- Linux文本处理三剑客之sed命令
- 文本处理命令-命令格式与目录处理命令ls
- 文本处理命令总结
- awk命令_Linux awk 命令用法详解:文本和数据进行处理的编程语言
- Linux运维文本处理三剑客之sed命令
- mac 文本处理命令分享
- linux 下的文本处理——除去重复行uniq命令
- Linux中关于文本查看和处理的常用命令
- 常见处理文本的SHELL命令
- Linux基础之文本处理命令(wc,cut,sort,uniq,diff,patch)