LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 02-25-2016, 02:15 PM   #16
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242

Quote:
Originally Posted by suicidaleggroll View Post
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.
 
Old 02-25-2016, 02:15 PM   #17
kernkraftx
LQ Newbie
 
Registered: Feb 2016
Location: Canada
Distribution: Suse Mint
Posts: 19

Original Poster
Rep: Reputation: Disabled
... ya thanks for the encouragement .
 
Old 02-25-2016, 02:20 PM   #18
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by grail View Post
Well my questions is ... how did this change from awk to bash all of a sudden? ... Talk about not paying attention
Espically after I explicitly gave him instructions on where to post his BASH.

Where are the results of your first homework assignment? Post them please in your orginal post for said homework.

Job Review:
Lacks focus and fails to follow instructions
 
Old 02-25-2016, 02:26 PM   #19
kernkraftx
LQ Newbie
 
Registered: Feb 2016
Location: Canada
Distribution: Suse Mint
Posts: 19

Original Poster
Rep: Reputation: Disabled
ya easier to criticize.
 
Old 02-25-2016, 02:34 PM   #20
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by kernkraftx View Post
ya easier to criticize.
Quote:
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.
Please now demonstrate some improvements
 
Old 02-26-2016, 11:28 AM   #21
kernkraftx
LQ Newbie
 
Registered: Feb 2016
Location: Canada
Distribution: Suse Mint
Posts: 19

Original Poster
Rep: Reputation: Disabled
Exclamation

ok then, I'll be back some with some good stuff.
 
Old 02-26-2016, 11:59 AM   #22
kernkraftx
LQ Newbie
 
Registered: Feb 2016
Location: Canada
Distribution: Suse Mint
Posts: 19

Original Poster
Rep: Reputation: Disabled
#!/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

awk




#!/bin/awk -f
BEGIN{somme=0
nombre=0
moyenne=0
}
{
somme=somme+$1
nombre++
}
END{
moyenne=somme/nombre
printf"Somme= %12.2f\n",somme
printf"Moyenne= %10.2f\n",moyenne
}

no more bashing me please....
 
Old 02-26-2016, 12:01 PM   #23
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Does it work? If not, how not?
 
Old 02-26-2016, 12:03 PM   #24
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
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.
 
Old 02-26-2016, 12:09 PM   #25
kernkraftx
LQ Newbie
 
Registered: Feb 2016
Location: Canada
Distribution: Suse Mint
Posts: 19

Original Poster
Rep: Reputation: Disabled
but it works dude....
 
Old 02-26-2016, 12:42 PM   #26
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by grail View Post
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:

[code]here comes your script[/code]

just to keep original formatting.

nope, thats it.

Last edited by BW-userx; 02-26-2016 at 01:01 PM.
 
Old 02-26-2016, 01:04 PM   #27
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
my output from your scripts

NOTICE HOW I PALCE IT BETWEEN [quote] quote tags [/quote] to make it look more better

Quote:
12:57 PM ~/testing$ ./oopsfrench

Entrer un nombre entier
Entrer q pour stopper
43566666

Entrer un nombre entier
Entrer q pour stopper
q
Somme= 43566666.00
Moyenne= 43566666.00
01:03 PM ~/testing$


Last edited by BW-userx; 02-26-2016 at 01:07 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] GPL question (Version 2, June 1991) - physical media availability question LicenseQuestions Linux - Newbie 1 12-01-2012 06:34 PM
basic html question - download link to files on my webpage question Davno Linux - Server 5 12-25-2009 07:24 AM
Question, Apples Contribution to Open Source + MacOs file structure question Higgy3k Other *NIX 5 07-25-2005 04:23 AM
Not your regular GRUB question - just a short question for a fried MBR!! ziphem Linux - General 3 01-31-2005 01:51 PM
login prompt question & kde scheme question JustinCoyan Slackware 2 06-09-2004 02:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration