Simple shell script in cygwin

#!/bin/bash
echo 'first line' >foo.xml
echo 'second line' >>foo.xml

I am a complete newbie to shell scripting.

I am trying to run the above script in cygwin. I want to be able to write one line after another in a new file.

However, when I execute the above script, I see the following content in the foo.xml file:

second line

The second time I run the script, I see in the file foo.xml:

second line
second line

etc.

In addition, I see the following error displayed on the command line after running the script:

: No such file or directory.xml

Ultimately, I will run this script in a unix window, I'm just trying to develop it with cygwin. So I would appreciate it if you could indicate if this is a weird cygwin, and if so, should I try to use cygwin to develop such scripts?

Thanks in advance.

+3
5

dos2unix script. .

+7

- . , , .

> foo.xml foo.xml, . >> foo.xml

+1

.. heredoc:

#!/bin/bash
cat <<EOF > foo.xml
first line
second line
EOF
+1

, . , , Windows , cygwin , , , , , :

echo 'first line' > 'My File.txt'
echo 'first line' > My\ File.txt

"" , , (&), (;) , , , / (.).

, , script, (.. , ), - , . , .

0

. script , , Cygwin , foo.xml, first line second line; , , , , - , .

- echo. script, ? ? ?

0

Source: https://habr.com/ru/post/1716834/


All Articles