Reputation: 4716
I use cygwin for Windows to run shell scripts. My script changes umlauts to LaTeX equivalents. It works.
I run the script via:
sh umlauts.sh
pause
This is my sed command, which perfectly works.
/usr/bin/find -name \*.tex | xargs -I p sed -i 's/ü/{\\"u}/g' p
However, running it twice in the same file leads to an error:
/usr/bin/find -name \*.tex | xargs -I p sed -i 's/ü/{\\"u}/g' p
/usr/bin/find -name \*.tex | xargs -I p sed -i 's/ä/{\\"a}/g' p
I get:
: no such file or directory.tex
Which looks like a strangely formatted message, as .tex is the ending of my file and should not be part of the error message.
This is probably a very trivial error. Why can't I write multiple lines of code into my script and run it successfully?
Upvotes: 1
Views: 1384
Reputation: 16999
Also avoid spaces after the backslash \ (trailing spaces), somehow it causes problems with my Cygwin. Luckily I did not have to use Windows after 2016.
Upvotes: 1
Reputation: 246774
Your script was written with a DOS editor and contains \r\n
line endings. *nix (including cygwin) uses \n
line endings, so the \r
character remains at the end of the sed p
command.
See if you have dos2unix
available, or run this command on the script
sed 's/\r$//' umlauts.sh
Upvotes: 3