I've got the following code:
cd /home/pi/.attract/romlists; for file in *.tag ; do grep -v -F 'Arcade Snooker [AGA]' $file > $file1.tmp && mv -f $file1.tmp $file; done
This works well to remove the fixed string "Arcade Snooker [AGA]" from a file such as "Amiga.tag". However, it does not remove the string from "Atari 800.tag" or from any other file that has a "space" in its name. The result for "Atari 800.tag" is the following error:
grep: Atari: No such file or directory
grep: 800.tag: No such file or directory
What changes do I need to make to the code please to get it to remove "Arcade Snooker [AGA]" from "Atari 800.tag" and from other such files containing spaces in their names?
I would prefer to have one line of code only please as I have it now.
Thanks.
如果文件名包含空格,则需要用引号引起来。
cd /home/pi/.attract/romlists; for file in *.tag ; do grep -v -F 'Arcade Snooker [AGA]' "$file" > "$file1.tmp" && mv -f "$file1.tmp" "$file"; done
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.