Shell-script

Parse passwd file and get ser input

Scripting to parse user input

shell 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 hosts

Add DNS if host does not exists

shell 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 domains

Hosting company domain expiration date

How 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 directory

Recursively remove all files in a CVS directory

for 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 itself

Clear analytics using shell script

goclearanalytics() { 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 scripting

Example of for loop statement

For 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 scripting

Bash Script to concatenate variables

Use the below code to concate two strings. Example var='My' var="${var}love" echo $var Output Mylove   ..

Pass argument with double quotes

Bash script - How to pass argument with quotes

Pass argument with double quotes If you want to pass argument with double quotes just follow the below step Create file as hello.sh and type as echo $1 Execute file as sh test.sh 'pp"' Output pp" Other way to Pass argument with double quotes is Execute file as sh hello.sh pp\" Execute file as  ..

Pass argument with single quote

Bash script to pass argument with single quote

Pass 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.   ..

Comment multiple lines in shell scripting

Bash script

How to comment multiple lines in shell script <<COMMENT1 //Your codes here COMMENT1 (or) <<comment1 //Your codes here comment1 Comment Multiple lines in shell script to comment multiple lines. Comment a particular line or single line If you want to comment the particular line use the # symbol. # Your code This will comment the line your code.   ..

How to comment a line in shell script

Comment a particular line in shell scripting

Comment the particular line If you want to comment the particular line use the # symbol. How to comment multiple lines in shell script <<COMMENT1 //Your codes here COMMENT1 (or) <<comment1 //Your codes here comment1 Comment Multiple lines in shell script to comment multiple lines.   ..

How to increment particular variable in shell script

Shell scripting increment a variable

Increment operation Use the below code to increment the particular variable. gg=0 gg=`expr $gg + 1` echo $gg expr command is used to increment the particular variable.   ..

How to execute shell script

Shell script beginning - Hello World

How to execute shell script Create file with extension as .sh Example: hello.sh echo $0 Execute File as # sh hello.sh Output of the above program is hello.sh   ..

Purge frozen messages in exim mail server

Delete frozen msg in exim server

Purge frozen messages in Exim # exipick -zi | xargs exim -Mrm The above command will delete all the frozen message in exim mail server. This command will be very much helpful when your exim mail server is frozen by mails. Delete frozen mails for i in `mailq | awk '$6 ~  ..

What is linux

Linus operating system

Linux is a free open-source operating system based on Unix. Linus Torvalds originally created Linux with the assistance of developers from around the world. Linux is: => Free => Unix Like => Open Source => Network operating system  ..

Previous 1 2 3 Next

Tech Bluff