Results 1 to 4 of 4

Thread: syntax error near unexpected token `if'

  1. #1
    Join Date
    Jan 2018
    Location
    Annandale, VA
    Posts
    105

    Default syntax error near unexpected token `if'

    I get

    linux-wbbw:~ # /usr/local/bin/importlocal
    /usr/local/bin/importlocal: line 3: syntax error near unexpected token `if'
    /usr/local/bin/importlocal: line 3: ` if [[ -d "$file" && ! -L "$file" ]]; then'
    linux-wbbw:~ #
    Running the code

    #!/bin/bash
    for file in /run/media/root/DFSFAT32/usr/local/bin/*
    if [[ -d "$file" && ! -L "$file" ]]; then
    dos2unix --keepdate --newfile --convmode iso -437 /run/media/root/DFSFAT32/usr/local/bin/$file /usr/local/bin/$file
    chmod -a -v 755 /usr/local/bin/$file
    fi;
    done
    for file in /run/media/root/DFSFAT32/usr/local/THE/*
    do
    if [[ -d "$file" && ! -L "$file" ]]; then
    dos2unix --keepdate -c iso -437 -n /run/media/root/DFSFAT32/usr/local/THE/$file /usr/local/THE/$file
    chmod -a -v 755 /usr/local/THE/$file
    fi;
    done

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,851

    Default Re: syntax error near unexpected token `if'

    Yoyr "for" has no "do", but is followed by an "if".

    BTW, when you are needing help with programming/scripting, there is a special sub-forum for it.
    Henk van Velden

  3. #3
    Join Date
    Jan 2018
    Location
    Annandale, VA
    Posts
    105

    Default Re: syntax error near unexpected token `if'

    Quote Originally Posted by hcvv View Post
    Yoyr "for" has no "do", but is followed by an "if".

    BTW, when you are needing help with programming/scripting, there is a special sub-forum for it.
    1. Metz's law - you see what you expect to see; that's what's nice about a fresh pair of eyes. In this case, two blocks of code with the "identical" structure were different; one did have the do.

    2. What is the forum for questions related to scripts? Thanks.

  4. #4
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,851

    Default Re: syntax error near unexpected token `if'

    Quote Originally Posted by shmuelmetz View Post
    1. Metz's law - you see what you expect to see; that's what's nice about a fresh pair of eyes. In this case, two blocks of code with the "identical" structure were different; one did have the do.

    Oh yes, that is very true. We humans are very good in seeing what we think we should see. Computers are stupid anough to only see what is there.

    Quote Originally Posted by shmuelmetz View Post
    2. What is the forum for questions related to scripts? Thanks.
    Quote Originally Posted by shmuelmetz View Post
    From the main page: Development. And then the top most Programming/Scripting.
    Henk van Velden

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •