Results 1 to 6 of 6

Thread: Error in bash file

  1. #1
    Join Date
    Jul 2009
    Posts
    24

    Error in bash file

    Hello friends,

    I had written a script for a work session, whenever i try to run the script i am getting an error message which is as follows

    line 6: syntax error near unexpected token
    Can anyone help me out with this error message ?

  2. #2
    Join Date
    Nov 2005
    Posts
    3,026

    Error in bash file

    Sure if you are getting line 6: syntax error near unexpected token, then it's an syntax error and i would be great if you can provide me your code so that i can help you out more in details.

  3. #3
    Join Date
    Jul 2009
    Posts
    24

    Error in bash file

    Thank you for replying me, please look into the code and tell me where i had made very silly mistake

    Code:
    / bin / sh
    
    while [-n $ 1]
    
    do
    
    list = ls $ 1
    
    for i in $ list
    
    do
    
    cat $ i>> basename $ i
    
    rm $ i
    
    done
    
    shift 1
    
    done

  4. #4
    Join Date
    Apr 2008
    Posts
    3,522

    Error in bash file

    In you case can you tell me how you want to make the difference between

    Code:
    color = blue  and list = ls $ 1
    If you want you can also replace
    Code:
    while [-n $ 1]
    do
     .... $ 1
    shift
    done
    by

    Code:
    for file in $ *
    do
     .... $ file
    done

  5. #5
    Join Date
    Jul 2009
    Posts
    1,179

    Error in bash file

    I am also facing some issue with my bash file whenever i try to manage to isolate, i can't know from where it has come from and i had created this file from a long back here is the code for the same.
    Code:
    / bin / bash
    while [-n $ 1]
    do
    if [[-n $ 1]]
    then
    echo X $ 1X not null;
    else
    echo X $ 1X null;
    fi
    shift 1
    done

  6. #6
    Join Date
    Dec 2008
    Posts
    164

    Error in bash file

    There is no need to worry about because you had to replace a very small code which i had done for you and i am sure this will solve all your problem here is the code for the same

    Code:
    / bin / bash
    while [-n "$1"]
    do
    if [[-n $ 1]]
    then
    echo X $ 1X not null;
    else
    echo X $ 1X null;
    fi
    shift 1
    done

Similar Threads

  1. Replies: 10
    Last Post: 09-01-2012, 07:48 AM
  2. Replies: 3
    Last Post: 28-01-2011, 06:26 AM
  3. "-bash: No such file or directory" (File exist)
    By first-born in forum Operating Systems
    Replies: 6
    Last Post: 13-11-2010, 07:45 AM
  4. Error shows bash: ns: command not found using ns-2.31
    By brynhildur in forum Operating Systems
    Replies: 3
    Last Post: 12-11-2010, 01:18 PM
  5. Bash script if then else help
    By Unix'EM in forum Software Development
    Replies: 3
    Last Post: 18-08-2009, 06:34 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,540,487.74183 seconds with 16 queries