Issue with sed used on multiple files
jil
-
jil -
jil -
Hello,
I am trying to replace a string with another in all text files in a given directory using sed, but I'm getting this error message:
sed: cannot read /home/moi/data-limit/Lien vers data/TEST/*.txt: No such file or directory
here is the problematic command:
sed -i -e 's/S1c \/ R1c/NA/g' '/home/moi/data-limit/Lien vers data/TEST/*.txt'
thanks for your tips...
I should mention that it works if I do it file by file by specifying the filename... It doesn't seem to like the wildcard for processing all the text files in the directory.
I am trying to replace a string with another in all text files in a given directory using sed, but I'm getting this error message:
sed: cannot read /home/moi/data-limit/Lien vers data/TEST/*.txt: No such file or directory
here is the problematic command:
sed -i -e 's/S1c \/ R1c/NA/g' '/home/moi/data-limit/Lien vers data/TEST/*.txt'
thanks for your tips...
I should mention that it works if I do it file by file by specifying the filename... It doesn't seem to like the wildcard for processing all the text files in the directory.
2 answers
Hello,
It's the spaces in the path that bother it (it = GNU/Linux) ;-(
You can either escape the spaces or quote them:
A few tips:
- Before using the "-i" option, it's better to test without it first, or prefer "-i.bak" to ensure a backup ;-\
- When modifying multiple files at once, the "-s" option can be very useful.
--
Zen my nuggets ;-)
Do a favor for the environment, close your windows and adopt a penguin.
It's the spaces in the path that bother it (it = GNU/Linux) ;-(
You can either escape the spaces or quote them:
/home/moi/data-limit/Lien\ vers\ data/TEST/ *.txt /home/moi/data-limit/'Lien vers data'/TEST/ *.txt
A few tips:
- Before using the "-i" option, it's better to test without it first, or prefer "-i.bak" to ensure a backup ;-\
- When modifying multiple files at once, the "-s" option can be very useful.
--
Zen my nuggets ;-)
Do a favor for the environment, close your windows and adopt a penguin.
Hi and thank you for your response, but it's strange because without space protection, with just one file, it works very well.
I might clarify that I am executing this command via the system command in the Octave software, which allows calling standard Linux commands in this program.
So, I have a kind of double constraint on special characters...
And since then, well I
I might clarify that I am executing this command via the system command in the Octave software, which allows calling standard Linux commands in this program.
So, I have a kind of double constraint on special characters...
And since then, well I