Did you know FaceySpacey is the creator of Redux-First Router and Universal?

The Startup Incubator.
Your one stop social media shop
Resource Categories:

Technical
Non-Technical
Refer A Friend
Popular Articles
DEVELOPMENT TOOLS 1 - VERSION CONTROL (Mercurial)
CONTRACTING 2 - TOP 10 EASY SITE CREATOR TOOLS
Subscribe
-
Technical
-
Linux
-
LINUX COMMANDS 1 - USING THE LINUX COMMAND LINE LINUX COMMANDS 2 - MORE LINUX COMMANDS LINUX COMMANDS 3 - SHELL SCRIPTING (Bash) LINUX TOOLS 1 - CRON JOBS LINUX TOOLS 2 - DAEMONS LINUX TOOLS 3 - DOCUMENTATION (Doxygen) SERVER SETUP 1 - SETTING UP LAMP & AMAZON WEB SERVICES SERVER SETUP 2 - CONNECTING YOUR DOMAIN NAME TO YOUR APPLICATION DIRECTORY SERVER SETUP 3 - INSTALLING Yii & YOUR APPLICATION
- LINUX COMMANDS 3 - SHELL SCRIPTING (Bash)
LINUX COMMANDS 3 - SHELL SCRIPTING (Bash)
The final lesson I’d like to teach in the Linux Commands section is an explanation of what “shell scripts” are. Shell scripts are simple scripts you can make that have multiple commands in them. Then you can just execute the shell script and all the commands written it will execute without you have to typing them one after another. You do this coding in a simple language called “BASH,” which is the language the Ubuntu shell uses. But for basic scripts you don’t really need to know any bash. You could write something like:
#!/bin/sh
cd /var/log
rm log-file-name1
rm log-file-name2
rm log-file-name3
The first line is just required for the script to work. The #! symbols together are called “shebang” and basically are a signifier that the following is a bash a script. Don’t worry about it much yet.
The next thing to think is: “Crap, I could trigger this script (or any other script) via a cron job” and have it do routine cleanup for me--in this case remove old log files.
So that’s an example of the power of shell scripting. There’s obviously a lot more you can do. For example, you can do loops and conditional logic like a PHP script--though you'll have to explore that on your own. For scripts that deal with your application’s database, you probably just want to write a PHP script using Yii’s “console application” tools, but for scripts that mainly deal in Linux commands, you definitely want to write a bash script.
Related Entries
- LINUX COMMANDS 1 - USING THE LINUX COMMAND LINE
- LINUX COMMANDS 2 - MORE LINUX COMMANDS
- LINUX COMMANDS 3 - SHELL SCRIPTING (Bash)
- LINUX TOOLS 1 - CRON JOBS
- LINUX TOOLS 2 - DAEMONS
- LINUX TOOLS 3 - DOCUMENTATION (Doxygen)
- SERVER SETUP 1 - SETTING UP LAMP & AMAZON WEB SERVICES
- SERVER SETUP 2 - CONNECTING YOUR DOMAIN NAME TO YOUR APPLICATION DIRECTORY
- SERVER SETUP 3 - INSTALLING Yii & YOUR APPLICATION
Comments

SMM 3 - FORMULA TO FIND INFLUENCERS