Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I recommend looking up a beginner's bash scripting guide. You have a lot of fundamental problems and inconsistencies with your syntax in this small block of code, such as:
1) Variable assignments must not have any spaces around the equal sign
2) Tests, such as 'if [[ "$var1 = "blah" ]]', MUST have spaces around the equal sign
3) Capturing the output of a command is done with $() or ``, you can't just say "var1=program", or it will set the variable "var1" to the string "program", rather than running the program and saving the output
4) Variable assignment is not done with "let"
You should also be posting your code in [code][/code] brackets to preserve formatting, such as indentation and white space.
He has already been advised about 97% of what you just advised him of, (yet again). Don't hold your breath on this one.
Constructive criticism is the process of offering valid and well-reasoned opinions about the work of others, usually involving both positive and negative comments, in a friendly manner rather than an oppositional one. The purpose of 'constructive criticism is to improve the outcome.
#!/bin/bash
#
#
#
clear
divZero="vrai"
sortie="faux"
while [ "$sortie" = "faux" ]
do
printf "%sEntrer un nombre entier\nEntrer "q" pour stopper\n"
read valeur
if ! [[ "$valeur" =~ ^[0-9]+$ ]] && ! [[ "$valeur" =~ "q" ]] ;
then
exec >&2; echo "Pas un nombre"
else
if [ "$valeur" = "q" ]
then
if [ "$divZero" = "vrai" ]
then
clear
printf "%sEntrer au moins un entier!\n"
else
let sortie="vrai"
fi
else
echo "$valeur" >> temp.tmp
divZero="faux"
clear
fi
fi
done
awk -f calcul.awk temp.tmp
rm temp.tmp
You still have not followed the first instruction you have received in nearly every post ... USE CODE TAGS.
Irrelevant of the fact that we all have to translate your code so we can understand what you are trying to do, without it being readable no one is going to help you.
You still have not followed the first instruction you have received in nearly every post ... USE CODE TAGS.
Irrelevant of the fact that we all have to translate your code so we can understand what you are trying to do, without it being readable no one is going to help you.
too bad you cannot increase the font size to something like 100pts, in red letters.
let me try
If you have a script to speak about please post it between code tags:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.