Home » Infrastructure » Unix » Copying (archiving) multiple files with sysdate
Copying (archiving) multiple files with sysdate [message #376278] Tue, 16 December 2008 16:27 Go to next message
oraclefaqs1
Messages: 23
Registered: October 2008
Location: SC
Junior Member

hi Everyone,

I wan't to copy multiple files which has names like

IBY_FD_PAYMENT_FORMAT_1987941_1.ETEXT
IBY_FD_PAYMENT_FORMAT_1987925_1.ETEXT
IBY_FD_PAYMENT_FORMAT_1987914_1.ETEXT

from one folder and archive them with sysdate in a different folder, which should look like

<SYSDATE>IBY_FD_PAYMENT_FORMAT_1987941_1.ETEXT
<SYSDATE>IBY_FD_PAYMENT_FORMAT_1987925_1.ETEXT
<SYSDATE>IBY_FD_PAYMENT_FORMAT_1987914_1.ETEXT

can anyone help me with this script. The way i tried is

SYSDATE="`date +%y%m%d%H%M%S`"
FROM_FILE=IBY*.ETEXT
ARCH_FILE=$SYSDATE$FROM_FILE
...
..
...
cp $FROM_FILE $XXAG_TOP/out/eft/archive/$ARCH_FILE


when I am trying to copy this way it says

cp: `/u01/oracle/DEV3/apps/apps_st/appl/xxag/12.0.0/out/eft/archive/081216113859IBY*.ETEXT': specified destination directory does not exist


can anyone please help me with this

thanks,
purnender kancharla

[Updated on: Tue, 16 December 2008 16:28]

Report message to a moderator

Re: Copying (archiving) multiple files with sysdate [message #376282 is a reply to message #376278] Tue, 16 December 2008 16:42 Go to previous messageGo to next message
ThomasG
Messages: 3211
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
OK, not really an Oracle question, but :

Creating a test case :

$ pwd
/tmp/test
$ touch testsdgsd.EXT
$ touch testadgsdg.EXT
$ touch testsdgbvsdgbs.EXT
$ touch asdgsadg.EXT
$ ls -l
total 0
-rw-r--r-- 1 thomas thomas 0 Dec 16 23:36 asdgsadg.EXT
-rw-r--r-- 1 thomas thomas 0 Dec 16 23:35 testadgsdg.EXT
-rw-r--r-- 1 thomas thomas 0 Dec 16 23:36 testsdgbvsdgbs.EXT
-rw-r--r-- 1 thomas thomas 0 Dec 16 23:35 testsdgsd.EXT
$ mkdir archive


And then it looks like a basic one-liner with xargs can do the job :

$ ls *.EXT| xargs -i@ mv @ /tmp/test/archive/`date +%y%m%d%H%M%S`@


And they have wound up in the archive directory with the date :

$ ls -l archive
total 0
-rw-r--r-- 1 thomas thomas 0 Dec 16 23:36 081216233829asdgsadg.EXT
-rw-r--r-- 1 thomas thomas 0 Dec 16 23:35 081216233829testadgsdg.EXT
-rw-r--r-- 1 thomas thomas 0 Dec 16 23:36 081216233829testsdgbvsdgbs.EXT
-rw-r--r-- 1 thomas thomas 0 Dec 16 23:35 081216233829testsdgsd.EXT
                                    
Re: Copying (archiving) multiple files with sysdate [message #376500 is a reply to message #376282] Wed, 17 December 2008 11:02 Go to previous message
oraclefaqs1
Messages: 23
Registered: October 2008
Location: SC
Junior Member

Thank you very much Thomas, it worked for me

I am new to oracle, and even UNIX...so trying to learn

cheers..
purnender

Previous Topic: Solaris Very Direct IO
Next Topic: How to set gobal enviroment vaibles in UNIX
Goto Forum:
  


Current Time: Fri Mar 29 01:57:21 CDT 2024