Wednesday 18 July 2012

Bash Script RealTime Examples





Back up files current location to remote location.

Shan: 

for example: #ssh avenca 'rm /u01/pthr/UNHCR/RAHRPTS/sqr/*'
#scp /u01/pthr/UNHCR/RAHRPRD/sqr/* avenca:/u01/pthr/UNHCR/RAHRPTS/sqr
#cd /u01/pthr/UNHCR/RAHRPRD/data
#find . -type d | cpio -oc -O /home/psofthr/scripts/dup_data_dir_hr.cpio
#scp /home/psofthr/scripts/dup_data_dir_hr.cpio avenca:/home/psofthr/scripts/


[16:20:28] … inthaku mundhu nuvvu cheppav ga,, backup tisi, remote desk loko pamputharu .cpio file ani...... ah file ni ekkadiki techukunnaka ee extract sctipt run chestam.. ekkada edhi am chestundhi..




[root@acai scripts]# more extract_data_dir.sh


#!/bin/ksh


target_sid=$1


module=`echo ${target_sid} | awk '{print substr($1,3,2)}'`


typeset -l module


cd /u01/pt${module}/UNHCR/${target_sid}/data


rm -rf `find /u01/pt${module}/UNHCR/${target_sid}/data/* -type d | grep -v 'SHARED'`


rm -f /u01/pt${module}/UNHCR/${target_sid}/data/*.*


cpio -i -I /home/psoft${module}/scripts/dup_data_dir_${module}.cpio


[root@acai scripts]#


=================
rey, linux lo find command use chesinapudu,
date format lo ravali ante yala?


13:34:52] … for example manam ls -lrt kodite,
wiwapnp01.svc.unicc.org:psoftfs (/home/psoftfs/scripts/housekeep) 


#ls -rlt
total 24976
-rw-r--r-- 1 psoftfs psoft       0 Dec 21  2011 housekeeplog_output_clear.log
-rwxr-xr-x 1 psoftfs psoft    1750 Jan  5  2012 log_output_clear_40.sh
-rw-r--r-- 1 psoftfs psoft     156 Jan 20 14:07 housekeep.parm




# find /etc -type f \!  -user root -exec ls -l {} \;
===================================================


How to list file names in a certain date range using ls command?


#ls -lt


list files in date order
or 


Code:
#ls -ltr
list files in reverse date order
-------


2.A script to find the files within a given date range


#more findDateRange.sh


#!/bin/ksh
#################################################
## File: findDateRange.sh
## Date: July 18, 2012
## Author: Sankar
## Purpose: A script to find the files within 
##a given date range
#################################################
echo "You have to provide the path, start date and the end date"
echo
echo "Enter the path to start search"
read fpath
echo "Please enter the start date in the format YYYYMMDD"
read strtdt
echo "please enter the end date in the format YYYYMMDD"
read enddt
touch -t ${strtdt}0000 /tmp/newerstart
touch -t ${enddt}2359 /tmp/newerend
#find ./ \( -newer /tmp/newerstart -a \! -newer /tmp/newerend \) -print
find $fpath \( -newer /tmp/newerstart -a \! -newer /tmp/newerend \) -exec ls -l {} \;

5 comments:

  1. hi Mr shankar..
    can u please tell me some real time issues u faced..
    and how we get work....and how we do it
    and who r assigned work to ours

    it will be helpfull to me to get a job

    Email : muthukuruuday@yahoo.com

    ReplyDelete
    Replies
    1. The Linux Stuff: Bash Script Realtime Examples >>>>> Download Now

      >>>>> Download Full

      The Linux Stuff: Bash Script Realtime Examples >>>>> Download LINK

      >>>>> Download Now

      The Linux Stuff: Bash Script Realtime Examples >>>>> Download Full

      >>>>> Download LINK 7C

      Delete
  2. hii shankar this scripts is very helpful me.
    thank you,

    i want to ask one question,

    How to take backup of remote server through shell script ?

    please send me the anser for this question

    Email-ID: kishore.bujji09@gmail.com

    ReplyDelete
  3. If possible explain the above program

    ReplyDelete
  4. The Linux Stuff: Bash Script Realtime Examples >>>>> Download Now

    >>>>> Download Full

    The Linux Stuff: Bash Script Realtime Examples >>>>> Download LINK

    >>>>> Download Now

    The Linux Stuff: Bash Script Realtime Examples >>>>> Download Full

    >>>>> Download LINK Ts

    ReplyDelete