简体   繁体   中英

Yjw to replace and then search with sed and find

I'm making a bash script which would call like

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

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 ~ -name "* echo "$1" | sed 's/\\.*//g' " -printf "%f\\n" -delete

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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