Remove all .html files - if else statement won't work [on hold]“echo 1 > /sys/block/sdX/device/delete”...

Is it possible to grow new organs through exposure to radioactivity?

How can I communicate my issues with a potential date's pushy behavior?

What are these funnel-looking green things in my yard?

An equality about sin function?

Why is statically linking glibc discouraged?

Do I have to cite common CS algorithms?

Why aren't rockets built with truss structures inside their fuel & oxidizer tanks to increase structural strength?

Create the least compressible picture

My cat is a houdini

Is this n-speak?

Modeling the uncertainty of the input parameters

Tempoverlustspiel

Does one make a shehecheyanu on "used" jewelry?

How is являться different from есть and быть

How far did Gandalf and the Balrog drop from the bridge in Moria?

Is there a way to encourage or even force airlines and booking engines to show options with overnight layovers?

Why does my purified Pokémon need to be healed?

Why did Saruman lie?

How big are the Choedan Kal?

The cat ate your input again!

Why aren't rainbows blurred-out into nothing after they are produced?

How do I call a 6 digit Austrailian phone number with a US based mobile phone?

Case Condition for two lines

Does EU compensation apply to flights where the departure airport closes check-in counters during protests?



Remove all .html files - if else statement won't work [on hold]


“echo 1 > /sys/block/sdX/device/delete” on all disks except predetermined listFrom Mysql query output to retrieve files in the file system and rename the filesBASH: �ls: command not found when typing 'ñ' by mistakeRecursively remove files with idx > 10,000find all directories (except `encoded`) in the working dir then delete all of themUsing basename to strip file extension and search for files with the same namePrint variable inside loopUsing linux command line, what is the easiest way to delete matching files in all subdirectories of other extensions?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















This is my first bash script. I need to remove all .html files from the current folder.



I have this:



#!/bin/bash

HTML_FILE_COUNT=$(find . -maxdepth 1 -type f -name "*.html" | wc -l)

echo "Remove $HTML_FILE_COUNT file(s) with .html extension (yes / no)?"

echo -n "Answer: "
read ANSWER

if [ [$ANSWER = "yes"] ]; then
echo "$(find . -maxdepth 1 -type f -name "*.html" -delete)"
echo "Files have been removed!"
elif [ [$ANSWER = "no"] ]; then
echo "No file has been removed!"
else
echo "Unknown command!"
fi


However, the if else block returns only Unknown command. What am I missing here?










share|improve this question







New contributor



baduker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by Kusalananda 16 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Kusalananda

If this question can be reworded to fit the rules in the help center, please edit the question.


















  • Note too that find is not really needed here as you could just as well have used ./*.html (unless you are afraid to match directories too).

    – Kusalananda
    16 hours ago


















0















This is my first bash script. I need to remove all .html files from the current folder.



I have this:



#!/bin/bash

HTML_FILE_COUNT=$(find . -maxdepth 1 -type f -name "*.html" | wc -l)

echo "Remove $HTML_FILE_COUNT file(s) with .html extension (yes / no)?"

echo -n "Answer: "
read ANSWER

if [ [$ANSWER = "yes"] ]; then
echo "$(find . -maxdepth 1 -type f -name "*.html" -delete)"
echo "Files have been removed!"
elif [ [$ANSWER = "no"] ]; then
echo "No file has been removed!"
else
echo "Unknown command!"
fi


However, the if else block returns only Unknown command. What am I missing here?










share|improve this question







New contributor



baduker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by Kusalananda 16 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Kusalananda

If this question can be reworded to fit the rules in the help center, please edit the question.


















  • Note too that find is not really needed here as you could just as well have used ./*.html (unless you are afraid to match directories too).

    – Kusalananda
    16 hours ago














0












0








0








This is my first bash script. I need to remove all .html files from the current folder.



I have this:



#!/bin/bash

HTML_FILE_COUNT=$(find . -maxdepth 1 -type f -name "*.html" | wc -l)

echo "Remove $HTML_FILE_COUNT file(s) with .html extension (yes / no)?"

echo -n "Answer: "
read ANSWER

if [ [$ANSWER = "yes"] ]; then
echo "$(find . -maxdepth 1 -type f -name "*.html" -delete)"
echo "Files have been removed!"
elif [ [$ANSWER = "no"] ]; then
echo "No file has been removed!"
else
echo "Unknown command!"
fi


However, the if else block returns only Unknown command. What am I missing here?










share|improve this question







New contributor



baduker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











This is my first bash script. I need to remove all .html files from the current folder.



I have this:



#!/bin/bash

HTML_FILE_COUNT=$(find . -maxdepth 1 -type f -name "*.html" | wc -l)

echo "Remove $HTML_FILE_COUNT file(s) with .html extension (yes / no)?"

echo -n "Answer: "
read ANSWER

if [ [$ANSWER = "yes"] ]; then
echo "$(find . -maxdepth 1 -type f -name "*.html" -delete)"
echo "Files have been removed!"
elif [ [$ANSWER = "no"] ]; then
echo "No file has been removed!"
else
echo "Unknown command!"
fi


However, the if else block returns only Unknown command. What am I missing here?







bash shell-script






share|improve this question







New contributor



baduker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question







New contributor



baduker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question






New contributor



baduker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 16 hours ago









badukerbaduker

1034 bronze badges




1034 bronze badges




New contributor



baduker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




baduker is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







put on hold as off-topic by Kusalananda 16 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Kusalananda

If this question can be reworded to fit the rules in the help center, please edit the question.









put on hold as off-topic by Kusalananda 16 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Kusalananda

If this question can be reworded to fit the rules in the help center, please edit the question.







put on hold as off-topic by Kusalananda 16 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Kusalananda

If this question can be reworded to fit the rules in the help center, please edit the question.













  • Note too that find is not really needed here as you could just as well have used ./*.html (unless you are afraid to match directories too).

    – Kusalananda
    16 hours ago



















  • Note too that find is not really needed here as you could just as well have used ./*.html (unless you are afraid to match directories too).

    – Kusalananda
    16 hours ago

















Note too that find is not really needed here as you could just as well have used ./*.html (unless you are afraid to match directories too).

– Kusalananda
16 hours ago





Note too that find is not really needed here as you could just as well have used ./*.html (unless you are afraid to match directories too).

– Kusalananda
16 hours ago










1 Answer
1






active

oldest

votes


















1














You need to have whitepsace between the [ ] brackets and your variables/string.



if [[ $ANSWER = "yes" ]]; then


...



elif [[ $ANSWER = "no" ]]; then





share|improve this answer


























  • This did the trick! Lesson learned. Thanks!

    – baduker
    16 hours ago











  • No problem - please mark it as an accepted answer. Thank you.

    – Paul Burrows
    16 hours ago




















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You need to have whitepsace between the [ ] brackets and your variables/string.



if [[ $ANSWER = "yes" ]]; then


...



elif [[ $ANSWER = "no" ]]; then





share|improve this answer


























  • This did the trick! Lesson learned. Thanks!

    – baduker
    16 hours ago











  • No problem - please mark it as an accepted answer. Thank you.

    – Paul Burrows
    16 hours ago
















1














You need to have whitepsace between the [ ] brackets and your variables/string.



if [[ $ANSWER = "yes" ]]; then


...



elif [[ $ANSWER = "no" ]]; then





share|improve this answer


























  • This did the trick! Lesson learned. Thanks!

    – baduker
    16 hours ago











  • No problem - please mark it as an accepted answer. Thank you.

    – Paul Burrows
    16 hours ago














1












1








1







You need to have whitepsace between the [ ] brackets and your variables/string.



if [[ $ANSWER = "yes" ]]; then


...



elif [[ $ANSWER = "no" ]]; then





share|improve this answer













You need to have whitepsace between the [ ] brackets and your variables/string.



if [[ $ANSWER = "yes" ]]; then


...



elif [[ $ANSWER = "no" ]]; then






share|improve this answer












share|improve this answer



share|improve this answer










answered 16 hours ago









Paul BurrowsPaul Burrows

1495 bronze badges




1495 bronze badges
















  • This did the trick! Lesson learned. Thanks!

    – baduker
    16 hours ago











  • No problem - please mark it as an accepted answer. Thank you.

    – Paul Burrows
    16 hours ago



















  • This did the trick! Lesson learned. Thanks!

    – baduker
    16 hours ago











  • No problem - please mark it as an accepted answer. Thank you.

    – Paul Burrows
    16 hours ago

















This did the trick! Lesson learned. Thanks!

– baduker
16 hours ago





This did the trick! Lesson learned. Thanks!

– baduker
16 hours ago













No problem - please mark it as an accepted answer. Thank you.

– Paul Burrows
16 hours ago





No problem - please mark it as an accepted answer. Thank you.

– Paul Burrows
16 hours ago



Popular posts from this blog

Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...