Windows Ubuntu Terminal Script not Working

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
0
down vote

favorite












for my bash programming assignment i have to create pipelines to process a file to find some patterns. I am currently using the Windows 10 Ubuntu App terminal. I Wrote the following the following :



echo "Processing Log Files..."
# error is the word I'm looking for in the files
grep error -A 1 logfile1.txt >> filter.txt
grep error -A 1 logfile2.txt >> filter.txt
echo "Done."


But when i run the file with the header #!/bin/sh I get this error:



Processing Log Files...
: Directory nonexistentoder.sh: cannot create filter.txt
: Directory nonexistentoder.sh: cannot create filter.txt
Done.


And when i run the code with the header #!/bin/bash i get this error:



Processing Log Files...
: No such file or directoryer.txt
: No such file or directoryer.txt
Done.


I honestly have no idea of why this happens, i changed the permissions of the files to the following:



drwxrwxrwx 0 root root 512 Mar 20 23:25 .
drwxrwxrwx 0 root root 512 Mar 20 13:59 ..
-rwxrwxrwx 1 root root 316 Mar 20 23:24 decoder.sh
-rwxrwxrwx 1 root root 52247 Mar 19 15:59 logfile1.txt
-rwxrwxrwx 1 root root 33142 Mar 19 15:59 logfile2.txt
-rwxrwxrwx 1 root root 239 Mar 19 15:39 mapping-sorted.txt









share|improve this question























  • Are you running the script as root or as a user ?
    – Panther
    Mar 21 at 5:54






  • 1




    Whenever you see text smooshed together like directoryer.txt the most likely issue is that the script has been created/saved with Windows line endings (CR/LF rather than plain LF)
    – steeldriver
    Mar 21 at 5:57










  • @steeldriver That might be the issue since in edition the files using a windows program, rather than a terminal editor
    – Diego Rodriguez
    Mar 21 at 6:11














up vote
0
down vote

favorite












for my bash programming assignment i have to create pipelines to process a file to find some patterns. I am currently using the Windows 10 Ubuntu App terminal. I Wrote the following the following :



echo "Processing Log Files..."
# error is the word I'm looking for in the files
grep error -A 1 logfile1.txt >> filter.txt
grep error -A 1 logfile2.txt >> filter.txt
echo "Done."


But when i run the file with the header #!/bin/sh I get this error:



Processing Log Files...
: Directory nonexistentoder.sh: cannot create filter.txt
: Directory nonexistentoder.sh: cannot create filter.txt
Done.


And when i run the code with the header #!/bin/bash i get this error:



Processing Log Files...
: No such file or directoryer.txt
: No such file or directoryer.txt
Done.


I honestly have no idea of why this happens, i changed the permissions of the files to the following:



drwxrwxrwx 0 root root 512 Mar 20 23:25 .
drwxrwxrwx 0 root root 512 Mar 20 13:59 ..
-rwxrwxrwx 1 root root 316 Mar 20 23:24 decoder.sh
-rwxrwxrwx 1 root root 52247 Mar 19 15:59 logfile1.txt
-rwxrwxrwx 1 root root 33142 Mar 19 15:59 logfile2.txt
-rwxrwxrwx 1 root root 239 Mar 19 15:39 mapping-sorted.txt









share|improve this question























  • Are you running the script as root or as a user ?
    – Panther
    Mar 21 at 5:54






  • 1




    Whenever you see text smooshed together like directoryer.txt the most likely issue is that the script has been created/saved with Windows line endings (CR/LF rather than plain LF)
    – steeldriver
    Mar 21 at 5:57










  • @steeldriver That might be the issue since in edition the files using a windows program, rather than a terminal editor
    – Diego Rodriguez
    Mar 21 at 6:11












up vote
0
down vote

favorite









up vote
0
down vote

favorite











for my bash programming assignment i have to create pipelines to process a file to find some patterns. I am currently using the Windows 10 Ubuntu App terminal. I Wrote the following the following :



echo "Processing Log Files..."
# error is the word I'm looking for in the files
grep error -A 1 logfile1.txt >> filter.txt
grep error -A 1 logfile2.txt >> filter.txt
echo "Done."


But when i run the file with the header #!/bin/sh I get this error:



Processing Log Files...
: Directory nonexistentoder.sh: cannot create filter.txt
: Directory nonexistentoder.sh: cannot create filter.txt
Done.


And when i run the code with the header #!/bin/bash i get this error:



Processing Log Files...
: No such file or directoryer.txt
: No such file or directoryer.txt
Done.


I honestly have no idea of why this happens, i changed the permissions of the files to the following:



drwxrwxrwx 0 root root 512 Mar 20 23:25 .
drwxrwxrwx 0 root root 512 Mar 20 13:59 ..
-rwxrwxrwx 1 root root 316 Mar 20 23:24 decoder.sh
-rwxrwxrwx 1 root root 52247 Mar 19 15:59 logfile1.txt
-rwxrwxrwx 1 root root 33142 Mar 19 15:59 logfile2.txt
-rwxrwxrwx 1 root root 239 Mar 19 15:39 mapping-sorted.txt









share|improve this question















for my bash programming assignment i have to create pipelines to process a file to find some patterns. I am currently using the Windows 10 Ubuntu App terminal. I Wrote the following the following :



echo "Processing Log Files..."
# error is the word I'm looking for in the files
grep error -A 1 logfile1.txt >> filter.txt
grep error -A 1 logfile2.txt >> filter.txt
echo "Done."


But when i run the file with the header #!/bin/sh I get this error:



Processing Log Files...
: Directory nonexistentoder.sh: cannot create filter.txt
: Directory nonexistentoder.sh: cannot create filter.txt
Done.


And when i run the code with the header #!/bin/bash i get this error:



Processing Log Files...
: No such file or directoryer.txt
: No such file or directoryer.txt
Done.


I honestly have no idea of why this happens, i changed the permissions of the files to the following:



drwxrwxrwx 0 root root 512 Mar 20 23:25 .
drwxrwxrwx 0 root root 512 Mar 20 13:59 ..
-rwxrwxrwx 1 root root 316 Mar 20 23:24 decoder.sh
-rwxrwxrwx 1 root root 52247 Mar 19 15:59 logfile1.txt
-rwxrwxrwx 1 root root 33142 Mar 19 15:59 logfile2.txt
-rwxrwxrwx 1 root root 239 Mar 19 15:39 mapping-sorted.txt






command-line bash grep windows-subsystem-for-linux






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 21 at 10:54









Drakonoved

7421515




7421515










asked Mar 21 at 5:46









Diego Rodriguez

211




211











  • Are you running the script as root or as a user ?
    – Panther
    Mar 21 at 5:54






  • 1




    Whenever you see text smooshed together like directoryer.txt the most likely issue is that the script has been created/saved with Windows line endings (CR/LF rather than plain LF)
    – steeldriver
    Mar 21 at 5:57










  • @steeldriver That might be the issue since in edition the files using a windows program, rather than a terminal editor
    – Diego Rodriguez
    Mar 21 at 6:11
















  • Are you running the script as root or as a user ?
    – Panther
    Mar 21 at 5:54






  • 1




    Whenever you see text smooshed together like directoryer.txt the most likely issue is that the script has been created/saved with Windows line endings (CR/LF rather than plain LF)
    – steeldriver
    Mar 21 at 5:57










  • @steeldriver That might be the issue since in edition the files using a windows program, rather than a terminal editor
    – Diego Rodriguez
    Mar 21 at 6:11















Are you running the script as root or as a user ?
– Panther
Mar 21 at 5:54




Are you running the script as root or as a user ?
– Panther
Mar 21 at 5:54




1




1




Whenever you see text smooshed together like directoryer.txt the most likely issue is that the script has been created/saved with Windows line endings (CR/LF rather than plain LF)
– steeldriver
Mar 21 at 5:57




Whenever you see text smooshed together like directoryer.txt the most likely issue is that the script has been created/saved with Windows line endings (CR/LF rather than plain LF)
– steeldriver
Mar 21 at 5:57












@steeldriver That might be the issue since in edition the files using a windows program, rather than a terminal editor
– Diego Rodriguez
Mar 21 at 6:11




@steeldriver That might be the issue since in edition the files using a windows program, rather than a terminal editor
– Diego Rodriguez
Mar 21 at 6:11










1 Answer
1






active

oldest

votes

















up vote
2
down vote













Thanks to @steeldriver I found out that the script i wrote had hidden windows characters, since i was using a windows text editor. I ran the following line, and the file had the header #!/bin/bash.



dos2unix scriptName.sh


the script worked afterwards :D






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1017829%2fwindows-ubuntu-terminal-script-not-working%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    Thanks to @steeldriver I found out that the script i wrote had hidden windows characters, since i was using a windows text editor. I ran the following line, and the file had the header #!/bin/bash.



    dos2unix scriptName.sh


    the script worked afterwards :D






    share|improve this answer
























      up vote
      2
      down vote













      Thanks to @steeldriver I found out that the script i wrote had hidden windows characters, since i was using a windows text editor. I ran the following line, and the file had the header #!/bin/bash.



      dos2unix scriptName.sh


      the script worked afterwards :D






      share|improve this answer






















        up vote
        2
        down vote










        up vote
        2
        down vote









        Thanks to @steeldriver I found out that the script i wrote had hidden windows characters, since i was using a windows text editor. I ran the following line, and the file had the header #!/bin/bash.



        dos2unix scriptName.sh


        the script worked afterwards :D






        share|improve this answer












        Thanks to @steeldriver I found out that the script i wrote had hidden windows characters, since i was using a windows text editor. I ran the following line, and the file had the header #!/bin/bash.



        dos2unix scriptName.sh


        the script worked afterwards :D







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 21 at 6:24









        Diego Rodriguez

        211




        211



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1017829%2fwindows-ubuntu-terminal-script-not-working%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            pylint3 and pip3 broken

            Missing snmpget and snmpwalk

            How to enroll fingerprints to Ubuntu 17.10 with VFS491