Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hello! I am new to Linux I need help with BASH scripting,
#1
Hi friends, I am new to Linux but I am actually liking it. I have learned a few basics on how to navigate the command line in terminal. However, I need to be able to write a few scripts in Bash. I could use some tips on what is the best way to do this. If someone out there is able to help me please reach out to me, Thanks to the creator of this forum EzeeTalk. I hope this is the right place for my question if not please let me know so I can delete it thanks Shy
Reply
#2
Joe Collins has some good Bash scripting videos for beginners. See also Kris Occhipinti https://www.youtube.com/channel/UCf93fPK...7H3_KDcRyg and Luke Smith https://www.youtube.com/channel/UC2eYFnH...Imy1mTYvhA.

Do an online search for Bash tutorials. There are plenty of them out there. Many of them are in PDF format and can be downloaded.

I have several scripts on GitHub that you can look at, the URL is below in my signature.
Rick Romig
"It's never wrong to introduce a child to Linux."
@ludditegeek
Rick's Tech Stuff
GitHub
Reply
#3
Welcome!

Also, check out this recent thread for a few recommended guides:

https://www.ezeelinux.com/talk/showthrea...light=bash
Reply
#4
welcome to Linux.

YouTube is a good place to start. Just search "BASH Script" There are many videos for beginners and novice. Most of them are really good. Joe has a few good ones on there as well. But I imagine you already know that.

Books are usually the next step.

It is free but There is a 30 second wait. it is worth it.
https://www.computer-pdf.com/operating-s...-bash.html

this is a direct link to another free one

https://www.tldp.org/HOWTO/pdf/Bash-Prog...-HOWTO.pdf

and of course GNUs bash pdf
https://www.gnu.org/software/bash/manual/bash.pdf

Any questions you might have about Linux, usually has an answer here in the EzeeTalk forums.

There are many knowledgeable Linux users in here. And a few Linux Jedi's. Your are in the right place.

Again, Welcome.
A computer without Microsoft is like a piece of chocolate cake without ketchup and mustard.


Telegram @eliasw4u
Reply
#5
(03-18-2020, 11:28 AM)akama22 Wrote: Hi friends, I am new to Linux but I am actually liking it. I have learned a few basics on how to navigate the command line in terminal. However, I need to be able to write a few scripts in Bash. I could use some tips on what is the best way to do this. If someone out there is able to help me please reach out to me, Thanks to the creator of this forum EzeeTalk. I hope this is the right place for my question if not please let me know so I can delete it thanks Shy
Hi akama22,

In addition to all the great recommendations on this thread, I suggest also watching these two YT vids:
Concise GNU Bash: An Introduction to Advanced Usage - James Panacciulli @ LinuxFest Northwest 2017
https://www.youtube.com/watch?v=BJ0uHhBkzOQ

Introduction to Advanced Bash Usage - James Pannacciulli @ OSCON 2014
https://www.youtube.com/watch?v=uqHjc7hlqd0

with the the accompanying pdf doc:
https://cdn.oreillystatic.com/en/assets/...tation.pdf

useful hands-on gems
Reply
#6
I'll add a few general tips that apply to learning any programming language:

Think in modules: Create a BASH script with just a few lines, run it to make sure it does what you thought it would, and then add those lines to the big BASH script you're working on.

Likewise include the line echo "muppets 1" in your script every so often, changing the number each time. That will give you a visual indicator of which parts of the script have executed for bug chasing purposes.

Most programming errors are caused by things you did almost right. Stuff like putting a comma where a period should be or mistaking a capital I (eye) for a 1 (one) or a lowercase l (el). These are also the most difficult errors to find.

And remember: To placate the computer programming spirits, you have to write the traditional "Hello World" script at least once:
#! /bin/bash/
echo "Hello World"


If all else fails, cuss and yell DWIM! at the computer. (DWIM = Do What I Meant!)
Reply
#7
BASH Scripts is Great but it can mess up the system if you goof up. Try a VM (Virtual Box) or find a an old junk machine to play with. If you mess up , no harm done! Timeshift backup is your friend.
Dos 3.2 to Win 10.
Main - Cinnamon 19.2
   Resistance Is Not Futile!
       It's voltage divided by current
Reply
#8
(06-15-2020, 07:00 PM)Skipayear Wrote: I'll add a few general tips that apply to learning any programming language:

Think in modules: Create a BASH script with just a few lines, run it to make sure it does what you thought it would, and then add those lines to the big BASH script you're working on.

Most programming errors are caused by things you did almost right. Stuff like putting a comma where a period should be or mistaking a capital I (eye) for a 1 (one) or a lowercase l (el). These are also the most difficult errors to find.
I have a library of functions I use quite often. It's a script containing a few commonly used global variables and various functions that I can call from a script. I also have a collection of routines and code snippets that I copy and paste into scripts. Old laptops and VMs are good for testing out concepts before putting them into "production."

Sometimes finding those typo bugs can be challenging but it's part of the fun. I run scripts in debug mode a lot and one of my favorite tools is shellcheck.

I'm always looking for ways to tweak my code. A script is never finished, only abandoned.
Rick Romig
"It's never wrong to introduce a child to Linux."
@ludditegeek
Rick's Tech Stuff
GitHub
Reply
#9
little codes to look out for. these are some that can damage your system.
Code:
$ rm

especially $ sudo rm


$ mv

especially $ sudo mv


$ dd
also anything done as root or Where sudo is used!
Use EXTREME caution when using any of these! these are some of the main dangerous codes. though there are others, like don't mess with fstab unless you are absolutely sure you know what you are doing. always have a backup of it.

Anytime you have a script that will change a file, create a backup of it first. This is simple,
Code:
cp file_to_change file_to_change.bak
This simple step in the code placed before any change to the file will save you from many, many headaches.
Because if the script boinks the file, just do the same in reverse.

Code:
cp file_to_change.bak file_to_change
and all is back to normal. backside saved.



kudos
A computer without Microsoft is like a piece of chocolate cake without ketchup and mustard.


Telegram @eliasw4u
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)