Find the answer to your Linux question:
Results 1 to 2 of 2

Thread: loop problem

Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Exclamation loop problem

    hi im made a loop but idk where the error is can someone please help me?


    if [[ OPTARG2=="" ]]; then find \ -type f -name $OPTARG
    else -exec basename {} \; | grep -i '^['$OPTARG1'-'$OPTARG2'].*$'

  2. #2
    what are you trying to do? there are several things wrong w/your code.

    that is not a loop, just an if-else statement.

    if you want to check if the OPTARG2 variable is empty, you need to use the dollar sign to indicate that it is a variable:

    if [ "$OPTARG2" == ''" ]; then

    or maybe

    if [ -z "$OPTARG2" ]; then

    after that, you've got your "else" mixed into your find command, i think? again, indicate what it is exactly that you are trying to accomplish w/your code.

Posting Permissions

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