[shell] 文本操作

来源:互联网 发布:ug编程可疑几何体 编辑:程序博客网 时间:2024/06/05 11:06

1. 查看TCP端口

$ lsof -iTCP -sTCP:LISTEN -P -n

2. 合并一个文件中的相邻奇偶行

$ seq 10 | xargs -n2 echo

结果

3. 删除文件中的奇数行或者偶数行

$ cat file | awk '{if(NR % 2==0) print}' > even$ cat file | awk '{if(NR % 2==1) print}' > odd
1 0
原创粉丝点击