AboutWelcome to Free Software Daily (FSD). FSD is a hub for news and articles by and for the free and open source community. FSD is a community driven site where members of the community submit and vote for the stories that they think are important and interesting to them. Click the "About" link to read more...
Familiarity with command prompts and shell scripts is still necessary if you want to get the most from your GNU/Linux system, but the less time you spend doing that the better, right? Two powerful ways to minimize your time at the command line are shell aliases and functions.
Linux has become so idiot proof nowadays that there is less and less need to use the command line. However, the commands and shell scripts have remained powerful for advanced users to utilize to help them do complicated tasks quickly and efficiently. To those of you who are aspiring to become a UNIX/Linux guru... there are plenty of cheat sheets available on the web and on books.
I've always wanted to know how to create command line options for my Bash scripts. After some research I found there are two functions available to handle this; getopt and getopts. I'm not going to get into the debate about which one is better. getopts is a shell builtin and seems a little easier to implement than getopt, so I'll go with that for now.
There are some misconceptions that shell scripts are only for a CLI environment. You can easily use various tools to write GUI and/or network (socket) scripts under KDE or Gnome desktops.
The first time I played with Zenity, I recognized several potential uses for it. While I'm pretty comfortable with interacting with computers with a command line interface, I know many people are not. Zenity creates GUI widgets from a simple command line and can be used from any shell script.
In the last article I talked about simple command pipelines, one of the features that makes the Linux command line so powerful and so worth learning. So if you want to get comfortable using the command line, here are some tips that will make it a lot easier.
Both the ~/.bashrc and ~/.bash_profile are scripts that might be executed when bash is invoked. The ~/.bashrc file gets executed when you run bash using an interactive shell that is not a login shell. The ~/.bash_profile only gets executed during a login shell. What does this all mean?
Scripts are files that contain shell commands which may be short or can be very complex. Scripts just make it easier because you can invoke one command to run all of the commands in the script. Here instead of using 8 separate commands you can use one command to execute all of them.