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

时间:2021-01-07 19:32:04

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

1 个解决方案

#1


1  

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”-delete

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

如果你需要从root或home中搜索,请使用/或〜中的find命令

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

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

#1


1  

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”-delete

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

如果你需要从root或home中搜索,请使用/或〜中的find命令

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

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