Regular expressions in Linux -II

Regular Expression in Linux/Unix Part 2 This is our second part on Regular Expressions in Linux. Please have a look at our first part here. Interval Regular expressions These are used to mention no of character/character set reputation info. Note that interval regular expression and extended reg require -E option with grep Note: In order(…)

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. Basically regular expressions are divided in to 3 types for better understanding. 1)Basic Regular expressions 2)Interval Regular expressions (Use option -E for grep and -r for sed) 3)Extended Regular expressions (Use option -E for grep and -r for(…)

All about PIPESTATUS internal Variable in Linux

This is bit advanced topic, people new to Shell scripting and administration can skip this post. Today I have come across an awesome internal variable to get the piped command output status. Let me explain a scenario which I faced in automating a task. I am executing the following command to get two entries from(…)

How to find exit status of script or command in Linux?

Want to write meaningful scripts and become good Shell scripting expert? Then this post is for you. In Linux/Unix when you execute a command or a script, they will exit with a meaning full exit status for your understanding purpose. So that we can take necessary actions on the out come(pass, failed or partially completed)(…)

How to find expired user accounts in Linux

Q. I have a requirement to check whose accounts are expired in Linux machine and send a mail to root user about the accounts. How can i achieve this in Linux? Ans : Here is the script to check the account expires of the users in Linux #Created on:09-02-2010 #Last modified:02-05-2010 #Purpose:To check the user(…)

How To Search Multiple Files With grep

Search for a string in multiple files using grep Today we came across a requirement to check all the files in a directory for a specific entry. The situation is like this. We have two public DNS servers, we usually take backups of zone files when ever we do some changes to zone files. So(…)

How To List Only Alphabetical Filename in Linux

How to list Alphabetical Files and folders in Linux? Some times its required to list only alphabetical file names when listing a directory. A small script will help you in getting this.. for i in *; do egrep   ‘^[a-zA-Z]+$’ <<<“$i”; done Here we used reg-exp to grep only alphabets ie a-z and A-Z and nothing(…)

Linux Shell Script To Rename Files From Upper Case To Lower Case

Some times you want to rename a group of files to lower case from upper case.  This renaming can be achieved by using a shell script and a tr command which will translate upper case to lower case Here is my version of the script to do the activity. #Created on:02-02-2011 #Last modified:02-02-2011 #Purpose:To Convert(…)

How To Check The Status Of All The Services In Linux Using A Shell Script

How to write bash shell to check the state of all services which are running/stopped in Linux? Ans : #Created on:02-02-2011 #Last modified:02-02-2011 #Purpose:To Check the status of services #Author:Surendra Kumar Anne #The below for loop will take inputs from chkconfig command to check the services which are running/stoped on the machine. for i in(…)

Batch Programming (Dos Scripting) VS Shell Scripting

When I started my career in IT field, I have landed into windows world, as I know that no companies give chance to a fresher to work on production Linux/Unix servers. Its a good experience to work on DOS scripts(aka Batch programming). There are many similarities/differences/advantages/disadvantages between Batch programming and Shell scripting. Lets see what(…)