Shell-scriptHow to find smart array failed diskHP Array Configuration Utility CLI - hpacucliThe hpacucli utility which is used to add, delete, identify and repair logical and physical disks on the Smart array. Here we have used the hpacucli utility to identify the failure of the disk. #!/bin/bash pd=`hpacucli controller all show config | awk '$10 ~ "Fail" || $11 ~ "Fail" .. Replace newline tab space previous lineMove a line with tabe space to previous lineLets consider a file a called replace-newline.txt. Here our requirement is to move the line to a previous line and get the output to the device number. when the device number is printed in the next line we are unable to list or see the device number. And hence we .. Check the response of multiple serverNetcat - Test servers response timeBelow is a simple script to test multiple servers responce. Here we are testing whether the port 22 is open or not. for a in $(seq -f "mylin%04g" 411 1 414) do nc -zvw 2 $a 22 done Output: nc: connect to mylin0411 port 22 (tcp) timed out: Operation now in progress nc: connect to mylin412 .. How to find the length of a stringBasic string manipulationShell scripting, basic sting manipulation, how to find the length of a string # ${#my_string} The above will print the length of the sting variable Now lets see a example how to calculate the length of a string? Example: # vi find_string_length.sh #! /bin/bash str_Length="Welcome to the w3calculator" .. String manipulation cut last 10 characterCut first or Last ten charactersHow to cut first and last x characters of each line from a file? Before strating lets assume that we have a file course.txt, In this file we have alphabets and numeric digits. Lets have our goal set to extarct or parse the alphabets and numbers in to different variables. This .. Create multiple user same as in another serverBash script to crete user with passwordHow to create multiple users same as in another server? Sometime you might get a requirement to creare users same as in another server. At thet time you can use the below script to create users same as in another server. For creating such list you have to copy the specified .. How to fetch user details form etc passwd fileGet user details in argument or variableMany of my friends have asked me how to fetch the user details in each variable or field? They have said its required to use according to their different use. Some had said it was necessary when the need to user name and user details of their server. And other .. Parse passwd file and get ser inputScripting to parse user inputshell script to parse /etc/passwd file and place it as input How to find a user is present or not # grep -i 'avahi' /etc/passwd avahi-autoipd:x:170:170:Avahi IPv4LL Stack:/var/lib/avahi-autoipd:/sbin/nologin avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin The above command will grep for the user avahi and will grep the lines present in the server or /etc/passd file. Cut .. Bash script to add dns in etc hostsAdd DNS if host does not existsshell script to add DNS or host entry in /etc/hosts The below scrip will search for the given IP and the DNS or host in /etc/hosts file # Declare the ip which you want to add ip="127.0.0.1" # Execute grep command to find IP and store it .. Find domain expire date for list of domainsHosting company domain expiration dateHow to find domain expire date for list of domains? Sometime it is necessary to find the list of domain expiration date, which are hosted by you, To do so the below script will help you to find the domain expiration date. cat listdomain.txt | while read line; do .. How to remove all files in cvs directoryRecursively remove all files in a CVS directoryfor dir in $(find -type d ! -name CVS); do for file in $(find $dir -maxdepth 1 -type f); do rm $file; cvs delete $file; done; done This will search all directories and ignore the CVS ones. Then it .. Tell analytics to go itselfClear analytics using shell scriptgoclearanalytics() { echo "DELETE FROM moz_cookies WHERE name LIKE '__utm%';" | sqlite3 $( find ~/.mozilla -name cookies.sqlite ) } See, http://code.google.com/apis/analytics/docs/concepts/gaConceptsCookies.html if you are unclear about the Google Analytics cookie system. If Firefox is your daily browser, be a good Orwellian and run this command regularly. If you see, 'SQL error near .. For loop in shell scriptingExample of for loop statementFor loop in bash script Use the below code to print the particular string for 100 times using for loop Create hello.sh file echo $0 n=$1 for(( i = 1 ; i <=100 ; i++ )) do echo "$i $n " done Execute hello.sh file sh hello.sh mylove Output 1 mylove 2 mylove 3 mylove ........ ........ 100 mylove The above program will print mylove for 100 .. Concatenate two values in shell scriptingBash Script to concatenate variablesUse the below code to concate two strings. Example var='My' var="${var}love" echo $var Output Mylove .. Pass argument with single quoteBash script to pass argument with single quotePass argument with single quotes If you want to pass argument with single quotes just follow the below step Create file and type as echo $1 Execute file as sh hello.sh "pp'" Output: pp' Pass argument with single quotes sh hello.sh pp\' Execute file as above to pass the argument with single quote. .. |