简体   繁体   English

Yjw替换,然后用sed搜索并查找

[英]Yjw to replace and then search with sed and find

I'm making a bash script which would call like 我正在制作一个bash脚本,它会像

script.sh 172.16.1.1

trying to replace . 试图取代。 and search files to delete them but it won't happen 并搜索文件以将其删除,但不会发生

echo $1 | find -name '*.`sed 's/\.*//g'`' -printf "%f\n" -delete

files look like 文件看起来像

eth0-2:120.1721611  eth1-2:120.1721611

Try this command inside that script. 在该脚本中尝试此命令。
I think this may help you for your requirement. 我认为这可能会帮助您满足您的要求。

$ find -name "* echo "$1" | sed 's/\\.*//g' " -printf "%f\\n" -delete $ find -name“ * echo "$1" | sed 's/\\.*//g' ” -printf“%f \\ n”-删除

I am passing the name only for the particular field, If you passed for whole command it produce the different result. 我仅传递特定字段的名称,如果传递整个命令,则会产生不同的结果。

The given command is searched from current directory to end. 给定命令从当前目录搜索到末尾。

If you need to search from root or home use / or ~ in find command like 如果您需要从根目录或家庭中搜索,请使用/~在find命令中,例如

$ find ~ -name "* echo "$1" | sed 's/\\.*//g' " -printf "%f\\n" -delete $ echo "$1" | sed 's/\\.*//g' “ * echo "$1" | sed 's/\\.*//g' ” -printf“%f \\ n”-删除

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM