sed use case: Filter without editing
2024-09-06 05:06:52
if we want to filter with sed pattern and just print the filtered lines without any further editing , we can do it like this
ls -a1 ~ | sed -ne "/^\./p"
This command will print all dir entries that starts with "."
ls -a1 ~ | sed -ne "/^\./p" | sed -ne "/bash/p"
I want to find meta files related to bash, so I got the result:
.bash_history
.bash_logout
.bashrc
we can view each file content by
ls -a1 ~ | sed -ne "/^\./p" | sed -ne "/bash/p" | xargs -n less
delete file and directories except "term.sh" and "test.cpp"
ls | sed -e "/^term.sh$/d" | sed -e "/^test.cpp$/d" | xargs -n rm -rf
show contents of all status file in current directory tree
find . -iname status | xargs -n less
最新文章
- Linux环境下安装Oracle 10g 发生错误 You do not have permission to write to the inventory location
- dfs序 + RMQ = LCA
- cat命令在文件中插入内容
- 能不能对metronic继续封装一下呢
- vs2012出现无法启动iis express web 服务器的错误
- jQuery实现等比例缩放大图片让大图片自适应页面布局
- HDU 5619 Jam's store
- POJ 1631 Bridging signals &; 2533 Longest Ordered Subsequence
- Struts国际化
- Java对文件的16进制读取和操作
- 彻底清除Linux centos minerd木马
- 最长单词(一星级题目) 本来是很简单的,其实就是加个flag
- AC自动机讲解
- javascript中的Date对象和Math对象
- LabVIEW(七):多态VI
- ubuntu16.04 离线安装nginx
- java 集合排序
- Android JNI与多线程
- selenium page object模式
- SQL 存储过程分页