background preloader

Bash

Facebook Twitter

Bash Prompt HOWTO. NextPreviousContents 2. Regular Expressions in Linux Explained with Examples. Regular expressions (Regexp)is one of the advanced concept we require to write efficient shell scripts and for effective system administration.

Regular Expressions in Linux Explained with Examples

Basically regular expressions are divided in to 3 types for better understanding. Bash Shell Scripting Part II - MyLinuxBook. In the first part of this article series on shell scripting we covered basics of what shell scripting is and how we can use it like other programming languages to automate our work.

Bash Shell Scripting Part II - MyLinuxBook

Now we are going to cover some more advanced technique such as arrays, functions, networking etc which makes these shell scripts much more than just bunch of commands. A re-look at shell scripting part-1 In last article we saw some basics of bash variable, how we can create variables assign values to them and retrieve back their values. Bash also support some operation on these variables. Here are some of the operations that can be performed on them. var=”I am test string.

String Length $ echo ${#var} Output: 51 Substring Operations From given index Output: test string. From given index of given length. Bash Arrays. If you're used to a "standard" *NIX shell you may not be familiar with bash's array feature.

Bash Arrays

Although not as powerful as similar constructs in the P languages (Perl, Python, and PHP) and others, they are often quite useful. Bash arrays have numbered indexes only, but they are sparse, ie you don't have to define all the indexes. An entire array can be assigned by enclosing the array items in parenthesis: arr=(Hello World) Individual items can be assigned with the familiar array syntax (unless you're used to Basic or Fortran): arr[0]=Hello arr[1]=World. Bash Quoting. Quoting things in bash is quite simple... until it isn't.

Bash Quoting

I've written scripts where I'd swear 90% of the effort was getting bash to quote things correctly. The basics of quoting are simple, use single or double quotes when a value contains spaces: a="hello world"a='hello world' But single and double quotes are different. Single quotes don't support any kind of variable substitution or escaping of special characters inside the quoted string. Conditions in bash scripting (if statements) Linux Shell Script: Monitoring Activities.

Exclusive offer: get 50% off this eBook here Linux Shell Scripting Cookbook — Save 50% Solve real-world shell scripting problems with over 110 simple but incredibly effective recipes by Sarath Lakshman | January 2011 | Linux Servers Open Source An operating system consists of a collection of system software, designed for different purposes, serving different task sets.

Linux Shell Script: Monitoring Activities

Each of these programs requires to be monitored by the operating system or the system administrator in order to know whether it is working properly or not. In this article by Sarath Lakshman, author of Linux Shell Scripting Cookbook, we will cover: Disk usage hacksCalculating the execution time for a commandPrinting the 10 most frequently-used commandsListing the top 10 CPU consuming process in 1 hourMonitoring command outputs with watchRemote disk usage health monitoring. Linux Shell Script: Tips and Tricks. Exclusive offer: get 50% off this eBook here Linux Shell Scripting Cookbook — Save 50% Solve real-world shell scripting problems with over 110 simple but incredibly effective recipes by Sarath Lakshman | April 2011 | Linux Servers Open Source GNU/Linux is a remarkable operating system that comes with a complete development environment that is stable, reliable, and extremely powerful.

Linux Shell Script: Tips and Tricks

The shell, being the native interface to communicate with the operating system, is capable of controlling the entire operating system. In this article we will take a look at some of the tips and tricks on working with Linux Shell Script. (For more resources on Linux, see here.) Successful and unsuccessful command Tip: When a command returns after error, it returns a non-zero exit status. Specify -maxdepth and –mindepth as the third argument Tip: -maxdepth and –mindepth should be specified as the third argument to the find. -exec . $ grep "text" . This is one of the most frequently used commands by developers. 10 Tools To Add Some Spice To Your UNIX Shell Scripts. There are some misconceptions that shell scripts are only for a CLI environment.

10 Tools To Add Some Spice To Your UNIX Shell Scripts

You can easily use various tools to write GUI and/or network (socket) scripts under KDE or Gnome desktops. Shell scripts can make use of some of the GUI widget (menus, warning boxs, progress bars etc). You can always control the final output, cursor position on screen, various output effects, and so on. With the following tools you can build powerful, interactive, user friendly UNIX / Linux bash shell scripts.

Creating GUI application is not just expensive task but task that takes time and patience. . #1: notify-send Command The notify-send command allows you to send desktop notifications to the user via a notification daemon from the command line. Advanced Bash-Scripting Guide. Shell scripting. This tutorial is a three part series as an introduction to Bash Shell Scripting.

shell scripting

Part I is mainly basics of shell scripting and is generic, Part II will gradually move towards some more advanced techniques and focus mostly on the bash shell and finally in Part III we will try to use all the techniques to create working program. Tutorials - Zenity Brings a Little GUI Goodness to Linux Shell Scripts - Multi-Dialog Scripting. Dressing up Find September 3, 2009 By Paul Ferrill We'll need to do a little bash programming to show off some of Zenity's more powerful capabilities.

Tutorials - Zenity Brings a Little GUI Goodness to Linux Shell Scripts - Multi-Dialog Scripting

When you cascade multiple dialog boxes, you want to make it possible for a user to cancel the whole process when the "Cancel" button is clicked. This is done through the use of a special variable ($?) That Zenity sets when each dialog box exits. If [ $? The result codes include 1 for when the user clicks cancel, 0 for when the user clicks OK or close, -1 for an unexpected error and 5 to signify that the dialog timeout value has been reached. StrFilePath=$(zenity --file-selection --save --confirm-overwrite);echo $strFilePath The --timeout option will cause the dialog to close after specified number of seconds if no user input has been detected.