taniarascia / comments

Comments
7 stars 0 forks source link

how-to-create-and-use-bash-scripts/ #6

Open utterances-bot opened 4 years ago

utterances-bot commented 4 years ago

How to Create and Use Bash Scripts | Tania Rascia

Bash scripting is an extremely useful and powerful part of system administration and development. It might seem extremely scary the first…

https://tania.dev/how-to-create-and-use-bash-scripts/

wogelsby commented 4 years ago

Into What Directory should user Bash Scripts - either tutorial or purposeful - GO? Single, Multiple, whatever? Thank you for this concise, specific and stunningly simple tutorial which I will unpack and digest over the coming days.

taniarascia commented 4 years ago

Hi @wogelsby, it doesn't really matter where the scripts are located, as long as you follow the instructions for setting the proper permissions on them. Some tutorials will tell you to make a bin directory and put that in your path, but it's not necessary.

bobmoff commented 4 years ago

Well written article! 😎

biesior commented 4 years ago

Elegant set I’ll recommend it for every bash newcomer. ;)

biesior commented 4 years ago

@wogelsby that may depend on used OS and/or used additional package manager(s) in it.

Fastest check in your terminal $PATH like:

cat /etc/paths

and/or

echo $PATH

Most popular (i.e. on MacOS)

/usr/local/bin or /usr/local/sbin

For learning, teaching, private

On the other hand for learning, teaching and private-usage purposes I also suggest creating bin and sbin folders in your $HOME like:

mkdir $HOME/bin
mkdir $HOME/sbin

Exporting paths

in your $HOME/.profile (or $HOME/.bash_profile, depending on OS) export these paths like:

export PATH=$HOME/bin:$HOME/sbin:$PATH

back to the terminal, open a new window to include new exports, or source them in the current window like:

source $HOME/.profile
# or
# source $HOME/.bash_profile

check if your exports are included:

echo $PATH

You should see your new exported paths among others like /Users/you/bin:/Users/you/sbin:<other>

Then all scripts placed in $HOME/bin or $HOME/sbin will be available, just to remember to chmod +x after touching ;)

note

I deliberately use $HOME instead of ~ in this description, although personally I prefer the last one, the first is probably safer depending on OS.

wogelsby commented 4 years ago

Valuable info, biesior... appreciate it.

matiasdiez commented 4 years ago

Thank you. Best explanation for user begginers that I found!

David-E-Alvarez commented 4 years ago

“You can drink!” Lol I think I actually wrote something like that once

davidnnaji commented 4 years ago

Nice work here. Thanks for the help!

thisurathenuka commented 3 years ago

Wow! I just had to stop by and add a comment because this is as simple and clear as it can get. Very nice article. Thanks a lot. Everything is super clear and the article is not too long or short and has a nice flow.

KJMcGuire commented 3 years ago

A clear, concise, and helpful tutorial. Thanks for writing.

yaw4testing commented 3 years ago

Very great article Tiana. I am newbie to bash scripting. sometimes i get confused with some flags. for instance if [-z ls 4]. what's the meaning of -z?

acmaistvnet commented 3 years ago

hello, read a lot about bash, but still, no article like yours. so clean!!! loved the dark mode and indigo marks. this is really good progammer stuf!!!! have a nice day :)

rohan19094 commented 3 years ago

I was so stressed about my assignment but you just removed all my fear and anxiety about bash, thank you for this amazing article! 10/10

davidnnaji commented 2 years ago

Hey Tania, I think there's a typo on the output of this command:

echo -e "This string has a \new line"

It should be:

This string has a
ew line
brunojrpi commented 2 years ago

How to Create and Use Bash Scripts | Tania Rascia

Bash scripting is an extremely useful and powerful part of system administration and development. It might seem extremely scary the first…

https://tania.dev/how-to-create-and-use-bash-scripts/

Thanks for this very well presented information.

Kudawacho commented 1 year ago

Simply amazing.. for a beginner!