Jump to content

need help in developing a shell script very urgent


Recommended Posts

Posted

hi my requirement is  to develop a unix script

i have file with names 

20110130.xml
20110227.xml
20110329.xml
20110428.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





Posted

asalu requirement enti baa koncham clear ga cheppu
Naaku artham aindhi entante...oka file full_list.txt ane file undhi....andhulo ee file names unnai..
20110130. xml
20110227. xml
20110329. xml
20110428. 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???

Posted

I think this will give u idea

ls -ltr *.xml > tmp

tar -xvf tmp tmp.tar

where temp is directory name

Posted

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/bash
full_list=`cat full_list.txt`
for file_name in $full_list
do
name=`echo $file_name | cut -d'.' -f1`
find / -name $file_name -exec tar -cvzf ${name}.tar $file_name {} \;
done

Posted

sorry baa indhaka nenu ichina script thappu...
nenu misunderstanf cheskunna...

Posted

This should probably work.....change the names and directory structures accordingly to ur need...

#!/bin/bash
full_list=`cat /tmp/full_list.txt`
for file_name in $full_list
do
find /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

Posted

kadhu baa

directory path :    /srcFiles/abc

these are the files in that  directory

20110130. xml
20110227. xml
20110329. xml
20110428. xml
.
.
.
.
.
20080130. xml



i want to rename all the files in this directory to

20110130<sysdate>. xml
20110227<sysdate>. xml
20110329<sysdate>. xml
20110428<sysdate>. xml
.
.
.
.
.
20080130<sysdate>. xml

Posted

cd /srcFiles/abc
ls *.xml > full_list.txt
full_list=`cat full_list.txt`
sdate=`date +%Y_%m_%d`
for $oldname in $full_list
do
name=`echo $oldname | cut -d'.' -f1`
newname=${name}${sdate}.xml
mv $oldname $newname
done

test chesi use chesko...nuv first chepina requirement ki ipudu adigina dhaniki polika ledhu ga...any ways test it first...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...