You are Here:
Linux Lite 4.8 Final is now available for download and installation



Linux Shell Scripting Cookbook

Author (Read 1940 times)

0 Members and 1 Guest are viewing this topic.

Linux Shell Scripting Cookbook
« on: September 16, 2018, 09:53:21 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3185
    Posts
  • Country: 00
  • Reputation: 300

  • Linux Lite: 3.2 64bit
I heard about this book kindly from @Moltke

Thread for everyone to discuss bash learning from this book.

Last Edit: September 17, 2018, 07:47:37 AM by bitsnpcs
 


Re: Linux Shell Scripting Cookbook
« Reply #1 on: September 16, 2018, 10:00:24 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3185
    Posts
  • Country: 00
  • Reputation: 300

  • Linux Lite: 3.2 64bit
#2 on the same page

I used a lot of time and tried all kind of things for the increment exercise. Including all from Stack Exchange and AskUbuntu on questions about increments, not specifically this book or exercise.

Code: [Select]
let no1++
Eventually I tried changing the final line to

Code: [Select]
echo $no1
Rather than as I was using which was

Code: [Select]
echo $result
From earlier in #2 section.
Felt a bit silly but was glad I got there in the end.

Hope it saves someone some time in making the same mistake as I had.
 

Re: Linux Shell Scripting Cookbook
« Reply #2 on: September 16, 2018, 10:31:55 PM »
 

Moltke

  • Gold Level Poster
  • *******
  • 615
    Posts
  • Country: ve
  • Reputation: 77
  • Linux Lite Member

  • Linux Lite: 3.8 64bit

  • CPU: amd athlon 64 x2

  • MEMORY: 4Gb

  • VIDEO CARD: amd radeon hd 6750

  • Kernel: 4.x

Quote
I found 1 error to date,  page 37 of 384, #3 on the page.

@bitsnpcs I can't find that example on page 37. Are you sure it's the correct page? What's the lesson title/about?
Without each others help there ain't no hope for us :)
 

Re: Linux Shell Scripting Cookbook
« Reply #3 on: September 16, 2018, 10:38:52 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3185
    Posts
  • Country: 00
  • Reputation: 300

  • Linux Lite: 3.2 64bit

Quote
I found 1 error to date,  page 37 of 384, #3 on the page.

@bitsnpcs I can't find that example on page 37. Are you sure it's the correct page? What's the lesson title/about?

Page number on the actual book says Page 20 (of the chapter 1), page number for the entire book in the pdf reader says page 37 of 384.

It is in the Title "Math with the Shell", under #3


Last Edit: September 16, 2018, 10:42:53 PM by bitsnpcs
 

Re: Linux Shell Scripting Cookbook
« Reply #4 on: September 16, 2018, 10:39:13 PM »
 

Moltke

  • Gold Level Poster
  • *******
  • 615
    Posts
  • Country: ve
  • Reputation: 77
  • Linux Lite Member

  • Linux Lite: 3.8 64bit

  • CPU: amd athlon 64 x2

  • MEMORY: 4Gb

  • VIDEO CARD: amd radeon hd 6750

  • Kernel: 4.x
Without each others help there ain't no hope for us :)
 

Re: Linux Shell Scripting Cookbook
« Reply #5 on: September 16, 2018, 10:44:10 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3185
    Posts
  • Country: 00
  • Reputation: 300

  • Linux Lite: 3.2 64bit
@Moltke  Thank You :)
 

Re: Linux Shell Scripting Cookbook
« Reply #6 on: September 16, 2018, 10:51:40 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3185
    Posts
  • Country: 00
  • Reputation: 300

  • Linux Lite: 3.2 64bit
Is your page the same ?
Lets hope I don't have the special edition.
 

Re: Linux Shell Scripting Cookbook
« Reply #7 on: September 16, 2018, 11:41:24 PM »
 

Moltke

  • Gold Level Poster
  • *******
  • 615
    Posts
  • Country: ve
  • Reputation: 77
  • Linux Lite Member

  • Linux Lite: 3.8 64bit

  • CPU: amd athlon 64 x2

  • MEMORY: 4Gb

  • VIDEO CARD: amd radeon hd 6750

  • Kernel: 4.x
Quote
Is your page the same ?


Yes, it is @bitsnpcs  Btw, I tried the example and it gave me an error just like you said, but copying/pasting right from the book into the terminal does work. Check it out



I don't know why but it worked, so I guess that rather than being an error in the book there's something we're not doing or we're doing it wrong.

EDIT: I just found out what the problem was: we were using the " ' " symbol rather than " ` " as in the example. I noticed after running it again using the up arrow, since I copied/pasted the whole thing, I thought it should work that way and it did :) so it's no an error from the book. Thank you for this great idea about creating a thread for the books. :)
Last Edit: September 17, 2018, 05:52:06 AM by Moltke
Without each others help there ain't no hope for us :)
 

Re: Linux Shell Scripting Cookbook
« Reply #8 on: September 17, 2018, 07:47:14 AM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3185
    Posts
  • Country: 00
  • Reputation: 300

  • Linux Lite: 3.2 64bit
This is the result when using the ` instead of the '



This is the result not using ` or ' as per my playing with it, (the second running of the file in the terminal, the first is from the above version), the result it is how the book says it should look.




@Moltke you are correct, Copying/Pasting from the book or typing it in to the command line does produce 81.0.
It just fails when used as a script that is a file and I am still not sure why that is.

I will edit my earlier post about there being an error in the book.

I'll give this book a miss, I'll stick with the books at home for now.
I may try this book again once I have more experience and can follow it better.

I may even need the book @kpanic described to me "And a child can learn it (with the time they use inall those 'social media' sites)."
I can understand that eg; when learning a new language it is often that you use childrens books in the new language for the first books you read.
Last Edit: September 17, 2018, 08:37:04 AM by bitsnpcs
 

Re: Linux Shell Scripting Cookbook
« Reply #9 on: September 17, 2018, 03:39:45 PM »
 

Moltke

  • Gold Level Poster
  • *******
  • 615
    Posts
  • Country: ve
  • Reputation: 77
  • Linux Lite Member

  • Linux Lite: 3.8 64bit

  • CPU: amd athlon 64 x2

  • MEMORY: 4Gb

  • VIDEO CARD: amd radeon hd 6750

  • Kernel: 4.x
@bitsnpcs  in the first image you get an error because there cannot be spaces between "result=`echo" you wrote "result= `echo" and that's why it didn't work. The whole thing should look like this, with no spaces between " =` " in order to work as it is supposed to:
Code: [Select]
$ result=`echo "$no * 1.5" | bc`
Without each others help there ain't no hope for us :)
 

Re: Linux Shell Scripting Cookbook
« Reply #10 on: September 17, 2018, 03:48:04 PM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3185
    Posts
  • Country: 00
  • Reputation: 300

  • Linux Lite: 3.2 64bit
@Moltke Thank You, your instructions have solved it :)
Last Edit: September 17, 2018, 04:52:31 PM by bitsnpcs
 


Tags:
 


Linux Lite 4.8 Final is now available for download and installation