32kris Posted August 24, 2011 Report Share Posted August 24, 2011 hi my requirement is to develop a unix script i have file with names 20110130.xml20110227.xml20110329.xml20110428.xml.....20080130.xml one file for every month from 2008 to till date i want a script to find all these files and zip them . basically to search for a pattern and zip them Quote Link to comment Share on other sites More sharing options...
kiss4amiss Posted August 24, 2011 Report Share Posted August 24, 2011 asalu requirement enti baa koncham clear ga cheppuNaaku artham aindhi entante...oka file full_list.txt ane file undhi....andhulo ee file names unnai..20110130. xml20110227. xml20110329. xml20110428. xml.....20080130. xml so ipudu nuvu rase script full_list.txt file lo every line lo unna file name ni file system lo search chesi...aa file ekadundho telsukuni dhanni zip cheyaala??? Quote Link to comment Share on other sites More sharing options...
xrinz Posted August 24, 2011 Report Share Posted August 24, 2011 I think this will give u ideals -ltr *.xml > tmptar -xvf tmp tmp.tarwhere temp is directory name Quote Link to comment Share on other sites More sharing options...
kiss4amiss Posted August 24, 2011 Report Share Posted August 24, 2011 edho naaku telisina kastha knowledge tho...assuming full_list.txt contains the file names of *.xml, this would work...but give a try first.....#!/bin/bashfull_list=`cat full_list.txt`for file_name in $full_listdoname=`echo $file_name | cut -d'.' -f1`find / -name $file_name -exec tar -cvzf ${name}.tar $file_name {} \;done Quote Link to comment Share on other sites More sharing options...
kiss4amiss Posted August 24, 2011 Report Share Posted August 24, 2011 sorry baa indhaka nenu ichina script thappu...nenu misunderstanf cheskunna... Quote Link to comment Share on other sites More sharing options...
kiss4amiss Posted August 24, 2011 Report Share Posted August 24, 2011 This should probably work.....change the names and directory structures accordingly to ur need...#!/bin/bashfull_list=`cat /tmp/full_list.txt`for file_name in $full_listdofind /tmp -name $file_name -exec tar rvPf /tmp/dumpfile.tar {} \;done/tmp/ful_list.txt contains the list of the .xml file names/tmp/dumpfile.tar is the tar file need to be created.Here I am searching for files only in /tmp. Change accordingly Quote Link to comment Share on other sites More sharing options...
32kris Posted August 24, 2011 Author Report Share Posted August 24, 2011 kadhu baa directory path : /srcFiles/abcthese are the files in that directory20110130. xml20110227. xml20110329. xml20110428. xml.....20080130. xml i want to rename all the files in this directory to 20110130<sysdate>. xml20110227<sysdate>. xml20110329<sysdate>. xml20110428<sysdate>. xml.....20080130<sysdate>. xml Quote Link to comment Share on other sites More sharing options...
32kris Posted August 24, 2011 Author Report Share Posted August 24, 2011 i mean append sysdate befor the extension Quote Link to comment Share on other sites More sharing options...
kiss4amiss Posted August 24, 2011 Report Share Posted August 24, 2011 cd /srcFiles/abcls *.xml > full_list.txtfull_list=`cat full_list.txt`sdate=`date +%Y_%m_%d`for $oldname in $full_listdoname=`echo $oldname | cut -d'.' -f1`newname=${name}${sdate}.xmlmv $oldname $newnamedonetest chesi use chesko...nuv first chepina requirement ki ipudu adigina dhaniki polika ledhu ga...any ways test it first... Quote Link to comment Share on other sites More sharing options...
32kris Posted August 24, 2011 Author Report Share Posted August 24, 2011 ledhu bhayya this is fine thanks thankyou Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.