Find the answer to your Linux question:
Results 1 to 2 of 2
Dear Linux friends, I am a beginner of linux /bash. I have written a bash case...in...esac script and the script will not generate any file I expect. The following is ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2012
    Posts
    23

    bash: case in esac question


    Dear Linux friends,

    I am a beginner of linux /bash. I have written a bash case...in...esac script and the script will not generate any file I expect. The following is the simplified script but the structure is basically the same.
    I have "sh -n" and there is no error. When I "sh -x", everything seems running fine but just no files generated in the specified folder. (I have "chmod 777" for the files and folders)Please let me know if any comment. Thank you.

    #######################################
    #!/bin/bash
    cd /home/123

    case ${X} in
    "1")
    cat << EOF > group_min_l${X}

    AAAA_${X}

    EOF

    cat << EOF > mdin_min_v0_l${X}
    &cntrl
    imin = 1,
    clambda = 0.00922,
    EOF
    ;;
    "2")
    cat << EOF > group_min_l${X}

    bbb_${X}

    EOF

    cat << EOF > mdin_min_v0_l${X}
    &cntrl
    imin = 1,
    clambda = 0.04794,
    EOF
    ;;
    esac


    ####################################

    Cheers,
    Henry

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    have you defined $X before the case statement? It will not work, if you haven't.

Posting Permissions

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