Category Archives: Shell Script

My Shell Script Usage Collection

sgadmin created the topic: My Shell Script Usage Collection Count Total number of files in Directory and Subdirectory > find . -type f | wc –l Count Specific extention files in Directory and Subdirectory > find . -type f -name \*.mnp |wc –l Count only Directory > find . -type d | wc –l

How to read a .properties file through script

rajeshkumar created the topic: How to read a .properties file through script The easy way to do it is to note that a Java properties file has the same format as a basic shell script. However, there’s a trick to it. If you just run the properties file like so: sh appl.properties The assignments will… Read More »

Shell script to run x times

rajeshkumar created the topic: shell script to run x times Problem: First i need to cd to this directory $SWDIR/util Second i need to run the following either 4 times or 20 times ./swadm add_process 1 BG Y how can i put this in a script Regards, Rajesh Kumar Twitt me @ twitter.com/RajeshKumarIn rajeshkumar replied… Read More »

Whats the difference between running a shell scrip

scmuser created the topic: Whats the difference between running a shell scrip Whats the difference between running a shell script as ./script.sh and sh script.sh have a script that looks like this #!/bin/bash function something() { echo “hello world!!” } something | tee logfile I have set the execute permission on this file and when… Read More »

Perl commandline search and replace

rajeshkumar created the topic: Perl commandline search and replace Perl commandline search and replace The better option is using perl command line search and replace option. The syntax is the following. # perl -i.bak -p -e’s/old/new/g’ filename s/old/new/g what this does is searches for pattern “old” and replace it pattern “new”.The g option in does… Read More »

Unix command to find memory usage

rajeshkumar created the topic: unix command to find memory usage Monitor processes continuously. Updates every 3 seconds by default. Displays useful information such as total memory, memory in use, % of total memory used by each process, % cpu usage of each process, and process ID (PID) of each process. Type ‘h’ for help or… Read More »

Shell script merge two list and remove duplicates

rajeshkumar created the topic: shell script merge two list and remove duplicates You want all the records from list_A supplemented by all the records from list_B for which there is not already a matching name in list A. Mathematically this is: A + B – {w in B | (w,value) in A } \ There… Read More »

Shell script for recursive delete required.

rajeshkumar created the topic: Shell script for recursive delete required. #!/bin/bash if [ $# -ne 1 -o ! -d “$1” ] then echo “Usage $0 dirname” exit 1 fi find “$1” -type f -print | while read file do dir=$(dirname “$file”) dname=$(basename “$dir”) fname=$(basename “$file”) [ “$dname” = “$fname” ] && rm “$file” done Regards,… Read More »

Find Application Instance Directory In Unix

scmuser created the topic: find application instance directory in unix How to find installed application directory in unix? rajeshkumar replied the topic: Re:find application instance directory in unix use Which command I mean which java which perl which ant which p4 which svn You will get location of the apps installed in your machine. Regards,… Read More »

Shell Script to delete a folder that is more then

scmuser created the topic: Shell Script to delete a folder that is more then Shell Script to delete a folder that is more then 1 week old Hi all, i have this scritp set -x cd /var/log/ direc=”bkp_`date +%F`” mkdir $direc cp /var/log/*.log /tmp/bkp. — Here im ok, what i need is a scritp to… Read More »