Results 1 to 3 of 3

Thread: Help with case

  1. #1
    Join Date
    Mar 2004
    Posts
    8

    Unanswered: Help with case

    can anyone tell me why when i type in a filename with an asterisk it does not go to the selected case, eg cannot have an asterisk.

    Many Thanks!

    for file
    do
    case $file in
    *.*.*)
    echo Cannot have two dots
    exit
    ;;

    *'*'*)
    echo Cannot have an asterisk
    exit
    ;;

    *)
    echo This is a file
    ;;

    esac
    done

  2. #2
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    Try something like this :
    Code:
    for file
    do
       case $file in
          *.*.*)
             echo Cannot have two dots
             exit
             ;;
          *\**)
             echo Cannot have an asterisk
             exit
             ;;
          *)
             echo This is a file
             ;;
       esac
    done
    Jean-Pierre.

  3. #3
    Join Date
    Mar 2004
    Posts
    8
    Originally posted by aigles
    Try something like this :
    Code:
    for file
    do
       case $file in
          *.*.*)
             echo Cannot have two dots
             exit
             ;;
          *\**)
             echo Cannot have an asterisk
             exit
             ;;
          *)
             echo This is a file
             ;;
       esac
    done
    Many Thanks I will try it!

Posting Permissions

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