简体   繁体   中英

linux replacing code in all files

The system is Linux Debian 7 32bit.

I have problem when I try to replace some codes in all files in the same folder.

The file names for example is:

--ADBCABCD-.html

ABCDABCD.html

for example I want replace code < script > with < iframe > the command for replace

sed -i "s|< script >|< iframe >|g" *

I see this problem after I do this command

sed: invalid option -- 'A'
Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...

this because the files name Contain -- and -

same this file name --ADBCABCD-.html

please how I fix this problem I have a lot of files name Contain -- and -

Use a -- option. This is the most prevalent option in most Unix utilities.

sed -i -- 's/input/output/g' *
       ^^

Alternatively, while using glob for matching, add the directory prefix:

sed -i 's/aaa/bbb/' ./*

No one will treat ./-- as an option, right?

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