I want to delete all lines containing string "abcfk" from all the .xml files in current directory tree. I tried find . -name "*.xml" | xargs sed -i 's/abcfk//g'
find . -name "*.xml" | xargs sed -i 's/abcfk//g'
find . -name "*.xml" | xargs sed -i 's/abcfk//g'
but with this i can only replace..but not deleted the line. Any suggestions?
You could do:
sed -i '/abcfk/d' $(find . -name "*.xml")
note that s/abcfk//g
will leave empty lines, instead use /abcfg/d
to delete lines with abcfg
. Alternatively:
find . -name "*.xml" -exec sed -i '/abcfk/d' {} +
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.