In addition, so long as all of the commands that are referenced exist, scripts can work on multiple platforms with little to no tweaking required. Since it’s so universal, you should be able to script regardless of your platform. Bash is available for Mac OS users and Cygwin on Windows, too. We’ll be using the bash shell, which most Linux distributions use natively. Need to do something repetitive and tedious? Script it! Need a shortcut for a really convoluted command? Script it! Want to build a really easy to use command-line interface for something? Script it! Before You Beginīefore we begin our scripting series, let’s cover some basic information. You get to program with commands you already know, while learning staples of most major programming languages. That’s really the power of scripting, I think. And, you don’t have to learn another language because you’re using what you already know: the command-line. Scripting allows you to use programming functions - such as ‘for’ loops, if/then/else statements, and so forth - directly within your operating system’s interface. Scripts aren’t just invocations of commands, either. You can automate backups and each copied file can have the current date appended to the end of its name.
You can invoke a command, like date, and use it’s output as part of a file-naming scheme. They also allow for far more useful functions, such as command substitution. Shell scripts allow us to program commands in chains and have the system execute them as a scripted event, just like batch files. Batch files in Windows, while useful, are a cheap imitation of shell scripts. It was a clever and neat way to get some things done, like run games in your high school computer lab when you couldn’t open system folders or create shortcuts. These were little text files that you could fill with commands to execute and Windows would run them in turn. Now, some of you who used Windows before using Linux may remember batch files. Most Linux distros today use Bash, and this is what you’re really entering commands into. Well, the command-line itself is a program: the shell. The more you use and learn the command-line, the more you see its potential. Like it or not, there are just some things that are done much more easily via this interface than by pointing and clicking. Being a Linux user means you play around with the command-line.