LinuxQuestions.org
Visit Jeremy's Blog.
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, 03:15 PM   #16
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware FreeBSD Win10 MX
Posts: 9,588

Rep: Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066

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, 03: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, 03:20 PM   #18
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware FreeBSD Win10 MX
Posts: 9,588

Rep: Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066
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, 03: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, 03:34 PM   #20
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware FreeBSD Win10 MX
Posts: 9,588

Rep: Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066
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, 12:28 PM   #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, 12:59 PM   #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, 01:01 PM   #23
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 19.1 MATE
Posts: 8,018
Blog Entries: 5

Rep: Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872Reputation: 2872
Does it work? If not, how not?
 
Old 02-26-2016, 01:03 PM   #24
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,767

Rep: Reputation: 3050Reputation: 3050Reputation: 3050Reputation: 3050Reputation: 3050Reputation: 3050Reputation: 3050Reputation: 3050Reputation: 3050Reputation: 3050Reputation: 3050
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, 01: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, 01:42 PM   #26
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware FreeBSD Win10 MX
Posts: 9,588

Rep: Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066
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 02:01 PM.
 
Old 02-26-2016, 02:04 PM   #27
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware FreeBSD Win10 MX
Posts: 9,588

Rep: Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066
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 02:07 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 07:34 PM
basic html question - download link to files on my webpage question Davno Linux - Server 5 12-25-2009 08:24 AM
Question, Apples Contribution to Open Source + MacOs file structure question Higgy3k Other *NIX 5 07-25-2005 05:23 AM
Not your regular GRUB question - just a short question for a fried MBR!! ziphem Linux - General 3 01-31-2005 02:51 PM
login prompt question & kde scheme question JustinCoyan Slackware 2 06-09-2004 03:02 PM

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

All times are GMT -5. The time now is 12:12 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration