简体   繁体   中英

How do I preg replace the following at linux command line

How do I preg replace the following at linux command line

<link rel="pear-icon" sizes="100" href="../../pear.png" />

I want to preg replace away the ../../ to make it become

<link rel="pear-icon" sizes="100" href="pear.png" />

Because there a lot of ../../ in my link, how do i mass preg replace and recursive on all file that contain this ../../

Thanks !

Something like this should do the trick:

find . -name "*.php" -print | xargs sed -i 's/"\.\.\/\.\.\/pear\.png/"pear\.png/g'

Try it first on 1 file though... didnt test this myself

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