Skip to content

Contains the scripts used in the shell scripting video series.

License

Notifications You must be signed in to change notification settings

AmaranthineTech/ShellScripts

Repository files navigation

ShellScripts

Disclaimer

The Software Is Provided "As Is", Without Warranty Of Any Kind, Express Or Implied, Including But Not Limited To The Warranties Of Merchantability, Fitness For A Particular Purpose And Noninfringement. In No Event Shall The Authors Or Copyright Holders Be Liable For Any Claim, Damages Or Other Liability, Whether In An Action Of Contract, Tort Or Otherwise, Arising From, Out Of Or In Connection With The Software Or The Use Or Other Dealings In The Software.

Table of contents

Topic Description Link
Topic 1 Basic script https://github.com/AmaranthineTech/ShellScripts#topic-1
Topic 2 Managing data https://github.com/AmaranthineTech/ShellScripts#topic-2
Topic 3 Condition checks https://github.com/AmaranthineTech/ShellScripts#topic-3
Topic 4 Documentation https://github.com/AmaranthineTech/ShellScripts#topic-4
Topic 5 Loops https://github.com/AmaranthineTech/ShellScripts#topic-5
Topic 6 User interaction https://github.com/AmaranthineTech/ShellScripts#topic-6
Topic 7 Miscellaneous https://github.com/AmaranthineTech/ShellScripts#topic-7
Topic 8 Arrays & Dictionaries https://github.com/AmaranthineTech/ShellScripts#topic-8
Topic 9 Automating scripts https://github.com/AmaranthineTech/ShellScripts#topic-9
Topic 10 Distribution https://github.com/AmaranthineTech/ShellScripts#topic-10

Topic 1

https://arunpatwardhan.com/2021/06/10/shell-scripting-in-macos-part-1/


The folderCreator.zsh script is the script from the first blog article.

You can download the script and make changes to it.

Running the script

Option 1:

zsh folderCreator.zsh

Option 2:

chmod ugo+x folderCreator.zsh
./folderCreator.zsh

This command assumes you are in the correct folder.

Topic 2

https://arunpatwardhan.com/2021/07/02/shell-scripting-in-macos-part-2/


The folderCreator_v1-1.zsh script is the script from the second blog article.

You can download the script and make changes to it.

Running the script

Option 1:

zsh folderCreator_v1-1.zsh <folder name 1> <folder name 2> <folder name 3>

Example:

zsh folderCreator_v1-1.zsh Tools Reports Help

Option 2:

chmod ugo+x folderCreator_v1-1.zsh
./folderCreator_v1-1.zsh <folder name 1> <folder name 2> <folder name 3>

Example:

./folderCreator_v1-1.zsh Tools Reports Help

This command assumes you are in the correct folder.

Topic 3

https://arunpatwardhan.com/2021/07/16/shell-scripting-in-macos-part-3-condition-checks/


The folderCreator_v1-2.zsh script is the script from the second blog article.

You can download the script and make changes to it.

Running the script

Option 1:

zsh folderCreator_v1-2.zsh <folder name 1> <folder name 2> <folder name 3>

Example:

zsh folderCreator_v1-2.zsh Tools Reports Help

Topic 4

https://arunpatwardhan.com/2021/07/08/shell-scripting-in-macos-part-4-documentation-and-help/


The folderCreator_v1-3.zsh script is the script from the third blog article.

You can download the script and make changes to it.

NOTE: Going forward the command will simply be referred to as folderCreator.zsh. Whenever, we mention this command we are talking about the version in context. So in this case, for topic 4, folderCreator.zsh simply refers to folderCreator_v1-3.zsh.

Running the script

Option 1:

zsh folderCreator.zsh <folder name 1> <folder name 2> <folder name 3>

Example:

zsh folderCreator.zsh Tools Reports Help

Option 2:

chmod ugo+x folderCreator.zsh
./folderCreator.zsh <folder name 1> <folder name 2> <folder name 3>

Example:

./folderCreator.zsh Tools Reports Help

These commands assumes you are in the correct folder.

Getting help

Option 1:

zsh folderCreator.zsh -h

Option 2:

./folderCreator.zsh -help

These commands assumes you are in the correct folder.

Getting the version number

Option 1:

zsh folderCreator.zsh -v

Option 2:

./folderCreator.zsh -version

These commands assumes you are in the correct folder.

Topic 5

https://arunpatwardhan.com/2022/12/19/shell-scripting-in-macos-part-5-loops/


The folderCreator_v1-4.zsh script is the script from the fifth blog article.

You can download the script and make changes to it.

NOTE: Going forward the command will simply be referred to as folderCreator.zsh. Whenever, we mention this command we are talking about the version in context. So in this case, for topic 5, folderCreator.zsh simply refers to folderCreator_v1-4.zsh.

Running the script

Option 1:

zsh folderCreator.zsh <folder name 1> <folder name 2> <folder name 3>

Example:

zsh folderCreator.zsh Tools Reports Help

Option 2:

chmod ugo+x folderCreator.zsh
./folderCreator.zsh <folder name 1> <folder name 2> <folder name 3>

Example:

./folderCreator.zsh Tools Reports Help

These commands assumes you are in the correct folder.

Getting help

Option 1:

zsh folderCreator.zsh -h

Option 2:

./folderCreator.zsh -help

These commands assumes you are in the correct folder.

Getting the version number

Option 1:

zsh folderCreator.zsh -v

Option 2:

./folderCreator.zsh -version

These commands assumes you are in the correct folder.

Topic 6

https://arunpatwardhan.com/2022/12/19/shell-scripting-in-macos-part-6-user-interaction/


The folderCreator_v1-5.zsh script is the script from the sixth blog article.

You can download the script and make changes to it.

NOTE: Going forward the command will simply be referred to as folderCreator.zsh. Whenever, we mention this command we are talking about the version in context. So in this case, for topic 6, folderCreator.zsh simply refers to folderCreator_v1-5.zsh.

Running the script

Option 1:

zsh folderCreator.zsh <folder name 1> <folder name 2> <folder name 3>

Example:

zsh folderCreator.zsh Tools Reports Help

Option 2:

chmod ugo+x folderCreator.zsh
./folderCreator.zsh <folder name 1> <folder name 2> <folder name 3>

Example:

./folderCreator.zsh Tools Reports Help

These commands assumes you are in the correct folder.

Getting help

Option 1:

zsh folderCreator.zsh -h

Option 2:

./folderCreator.zsh -help

These commands assumes you are in the correct folder.

Getting the version number

Option 1:

zsh folderCreator.zsh -v

Option 2:

./folderCreator.zsh -version

These commands assumes you are in the correct folder.

Topic 7

https://arunpatwardhan.com/2022/05/07/shell-scripting-in-macos-part-7-miscellaneous/


The folderCreator_v1-6.zsh script is the script from the third blog article.

You can download the script and make changes to it.

NOTE: Going forward the command will simply be referred to as folderCreator.zsh. Whenever, we mention this command we are talking about the version in context. So in this case, for topic 7, folderCreator.zsh simply refers to folderCreator_v1-6.zsh.

Running the script

Option 1:

zsh folderCreator.zsh <folder name 1> <folder name 2> <folder name 3>

Example:

zsh folderCreator.zsh Tools Reports Help

Option 2:

chmod ugo+x folderCreator.zsh
./folderCreator.zsh <folder name 1> <folder name 2> <folder name 3>

Example:

./folderCreator.zsh Tools Reports Help

These commands assumes you are in the correct folder.

Getting help

Option 1:

zsh folderCreator.zsh -h

Option 2:

./folderCreator.zsh -help

These commands assumes you are in the correct folder.

Getting the version number

Option 1:

zsh folderCreator.zsh -v

Option 2:

./folderCreator.zsh -version

These commands assumes you are in the correct folder.

Topic 8

https://arunpatwardhan.com/2023/01/25/shell-scripting-in-macos-part-8-arrays-dictionaries/


The folderCreator_v1-7.zsh script is the script from the third blog article.

You can download the script and make changes to it.

NOTE: Going forward the command will simply be referred to as folderCreator.zsh. Whenever, we mention this command we are talking about the version in context. So in this case, for topic 8, folderCreator.zsh simply refers to folderCreator_v1-7.zsh.

Running the script

Option 1:

zsh folderCreator.zsh <folder name 1> <folder name 2> <folder name 3>

Example:

zsh folderCreator.zsh Tools Reports Help

Option 2:

chmod ugo+x folderCreator.zsh
./folderCreator.zsh <folder name 1> <folder name 2> <folder name 3>

Example:

./folderCreator.zsh Tools Reports Help

These commands assumes you are in the correct folder.

Getting help

Option 1:

zsh folderCreator.zsh -h

Option 2:

./folderCreator.zsh -help

These commands assumes you are in the correct folder.

Getting the version number

Option 1:

zsh folderCreator.zsh -v

Option 2:

./folderCreator.zsh -version

These commands assumes you are in the correct folder.

Topic 9

https://arunpatwardhan.com/2023/01/25/shell-scripting-in-macos-part-9-automating-scripts/


This topic uses the answers.sh along with the questions.sh script together. The welcome.zsh is used along with the in.amaranthine.welcomeMessage.plist/

You can download the script and make changes to it.

NOTE: We do not use the folderCreator.zsh script in this article.

Expect utility

Running the script:

Example:

zsh answers.zsh

Setting up the Daemon

Preparing the script and daemon:

cp welcome.zsh /Library/Scripts
chmod 755 /Library/Scripts/welcome.zsh
sudo chown root:wheel /Library/Scripts/welcome.zsh

cp in.amaranthine.welcomeMessage.plist /Library/Launch\ Daemons/
chmod 644 /Library/Launch\ Daemons/in.amaranthine.welcomeMessage.plist
sudo chown root:wheel /Library/Launch\ Daemons/in.amaranthine.welcomeMessage.plist

Loading the daemon:

sudo launchctl bootstrap system /Library/Launch\ Daemons/in.amaranthine.welcomeMessage.plist

Checking to see if the daemon is running:

sudo launchctl list | grep "in.amaranthine.*"

Stopping the daemon:

sudo launchctl bootout system /Library/Launch\ Daemons/in.amaranthine.welcomeMessage.plist

These commands assumes you are in the correct folder.

Topic 10

https://arunpatwardhan.com/2023/02/02/shell-scripting-in-macos-part-10-distribution/


The folderCreator.zsh script is the script from the third blog article.

You can download the script and make changes to it.

NOTE: *Going forward the command will simply be referred to as folderCreator.zsh. Whenever, we mention this command we are talking about the version in context. *

Preparing the script

Step 1:

cp folderCreator.zsh /usr/local/bin/folderCreator
chmod 755 /usr/local/bin/folderCreator

Step 2:

folderCreator <folder name 1> <folder name 2> <folder name 3>

These commands assumes you are in the correct folder.

Loading the man page

Create man page folder:

cd /usr/local/share/man
mkdir man1

Copy the man page into this folder:

cp folderCreator.1 /usr/local/share/man/man1

Invoke the man page:

man folderCreator

NOTE: *In case none of the commands work as is then make sure you have placed the items in the correct folder. This will require admin access to the computer. The /usr folder is hidden in the GUI by default. *

These commands assumes you are in the correct folder.

Releases

No releases published

Packages

No packages published