如何用shell提取文件中指定的字符串

如题所述

##测试文件
cat 1234.txt

sdas
asdasdfa
sdfsf
asfsdfdfg
dfgdf
dfhf
asdasd
dfgdf

##执行脚本,在1234.txt中找字符串"fh"所在行
#!/bin/bash
sed -n '/fh/p' 1234.txt

##执行结果
dfhf

温馨提示:答案为网友推荐,仅供参考
相似回答