2

I'd like to sort my figlet fonts with testing, so I've decided to make a script, which will demonstrate figlet font one by one and will delete fonts I don't like. I've tried to find the solution for correct if-then condition inside while loop, but couldn't find one. Here's the script itself, but for now it just provides examples of all the fonts in the single scroll:

#!/bin/bash #script to test figlet fonts rm /usr/share/figlet/list.txt #delete old list ls /usr/share/figlet > /usr/share/figlet/list.txt #create new list filename='/usr/share/figlet/list.txt' n=1 while read line; do figlet -f $line Figlet echo -e "Press 0 if you don't like it, font will be deleted" read decision if [ "$decision" = "0" ]; then rm "/usr/share/figlet/$line" echo -e "Font deleted" else echo -e "Font saved" fi n=$((n+1)) done < $filename 

    1 Answer 1

    3

    The original problem, is that content of your file list is being fed to read decision and while cycle doesn't work as you expect. Though why do you need a list at all?

    Better to iterate through files with for cycle.

    #!/bin/bash for font in /usr/share/figlet/*; do figlet -f "$font" Figlet echo -e "Press 0 if you don't like it, font will be deleted" read decision if [ "$decision" = "0" ]; then rm "$font" echo -e "Font deleted" else echo -e "Font saved" fi done 
    1
    • @FCW If one of the answers solved your issue, please take a moment to accept it by clicking on the checkmark on the left. That will mark the question as answered and is the way that thanks are conveyed on the Stack Exchange sites.
      – terdon
      CommentedApr 22, 2019 at 12:26

    You must log in to answer this question.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.