Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6915559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:29:25+00:00 2026-05-27T09:29:25+00:00

I am very new to shell scripts and I have a basic image resizing

  • 0

I am very new to shell scripts and I have a basic image resizing script:

#!/bin/bash

isResizeAnotherImage=Y;
for isResizeAnotherImage in Y y N n
do
  echo "option entered before if: $isResizeAnotherImage";
  if [ $isResizeAnotherImage='Y' ] || [ $isResizeAnotherImage='y' ]; then
    echo "Enter the file name :  ";
    read imageFileName;
    read -p "Enter desired size:  " imageDesiredSize;
    mogrify -resize $imageDesiredSize $imageFileName 2>/dev/null;

    echo "Resize another image ? Y/N : ";
    read isResizeAnotherImage;
    echo "option entered in if: $isResizeAnotherImage";
  else
    echo "option entered : $isResizeAnotherImage";
    exit 1;
  fi;
done

Now, It resizes first image successfully, asks ‘Resize another image?’. Here, I enter ‘N’. But in the next loop, it shows that the value of flag has not been changed to ‘N’. So it enters the if condition.
Why is this happening and how to prevent it ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:29:26+00:00Added an answer on May 27, 2026 at 9:29 am

    Your indenting is a bit off which makes it hard to read your code.

    Ignoring that, what is your for-loop for? Is that supposed to be a while-loop? As I see it this is going to make your variable isResizeAnotherImage take the values YyNn and ignore what you have entered at the prompt. Change your for-loop to a while-loop and I suspect it will work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to bash scripts, and for my first script attempt I
I am very new to the shell scripting world. I have done some research
I very new to Python, and fairly new to regex. (I have no Perl
I still very new using Subversion. Is it possible to have a working copy
I am very new to creating webservers - and I have had several goes
I'm very new to shell scripting and i've been struggling with the following shell
I have a shell script that is created inside a php script (given full
Very new to web programming still and I don't really have a specific question
I'm very new in shell scripting, and I encountered a problem that is quite
First off I am very very new to shell scripting. I am trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.