我在.txt结尾的目录中有一个文件,但在名称总是不同之前。我想在文件中更改名称" http"。看到, 所以它不起作用,不幸的是,
| Grep txt \\ |. Grep "http"
编辑: 我有测试:
curl ftp://user:pw@ip:port/directory/ ls | grep" .txt" | xargs grep" http"
错误:curl:(6)无法解析主机:ls
curl ftp://user:pw@ip:port/directory/ printf"%s \ n" * .txt | xargs grep" http"
错误:
curl:(6)无法解析主机:printf curl:(6)无法解析主机:%s \ n curl:(6)无法解析主机:* .txt grep:无效选项 - &#39 ; - '用法:grep [OPTION] ... PATTERN [FILE] ...尝试' grep --help'了解更多信息。
答案 0 :(得分:1)
您可以执行以下操作:
ls | grep ".txt" | xargs grep "http"
感谢Jonathan的评论!它做得更好:
printf "%s\n" *.txt | xargs grep "http"
答案 1 :(得分:0)
您可以结合使用find
和grep
:
find /your/path -type f -name '*.txt' -exec grep http "{}" \;
您可以将其读作“在/ your / path中查找名称以.txt结尾并在其上运行grep http的文件”。