- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- find and cp -p
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 05:39 PM
12-04-2003 05:39 PM
I need to write a shell script to find files created in a /backup folder starting on 0000 hrs until current.
I also would like to copy the result into a different folder ie /dump
The script so far that I have is as below:
#!/bin/ksh
WorkingDir=/export/home/b2b_supp/aperak
Date=`date +%m%d`
DateN=$Date
echo "$DateN""0000" > $WorkingDir/mydate.txt
DateW=`cat $WorkingDir/mydate.txt`
touch -m $DateW $WorkingDir/datefile.txt
find /opt/cyclone/data/TOPSMAL01/backup -newer $WorkingDir/datefile.txt -name *out >> $WorkingDir/todayfiles_msia.lis
How do I cp -p the files found into another folder?
Thanks in advace
Zul
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 06:13 PM
12-04-2003 06:13 PM
Solutiontouch -mt ${DATE}0000 $WorkingDir/datefile.txt
As for the cp -p, you could do it like this:
find /opt/cyclone/data/TOPSMAL01/backup -newer $WorkingDir/datefile.txt -name '*out' -exec cp -p {}
Or you could use the lis file you create and use cpio or pax to copy the files.
A problem you might encounter, depending on where you like the files to be copied too, is the path the files have. Since you do the find with the absolute path, the complete directory will be copied. A better way might be to do a change directory to your backup directory and do a find from '.' .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 06:14 PM
12-04-2003 06:14 PM
Re: find and cp -p
pipe the output to cpio
find ...... |cpio -pdvmux
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 07:43 PM
12-04-2003 07:43 PM
Re: find and cp -p
Thanks for the kind input. Now I need to do some cleanup of the files that I copied into the /dump folder.
The file content would look like below as single line:-
UNA:+.? 'UNB+UNOA:3+9554000001105:14+3020476101404:14+031205:1313+23054++++0'UNH+2305400001+APERAK:D:96A:UN:EAN002'BGM+12E::9+33596+6'DTM+137:20031204:203'RFF+ON:142260085N'UNT+5+2305400001'UNZ+1+23054'
I only interested in the value after BGM+12E::9+ and before +6'DTM+137 which is 3359. I know that sed can do this but I could not get the correct command/syntax....
Again...many thanks in advance
Zul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 07:59 PM
12-04-2003 07:59 PM
Re: find and cp -p
expr "`cat myfike`" : ".*BGM+12E::9+\(.*\)+6'DTM+137.*"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 08:00 PM
12-04-2003 08:00 PM
Re: find and cp -p
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 08:02 PM
12-04-2003 08:02 PM
Re: find and cp -p
grep BGM file | sed 's;.*BGM+[^+]*+\([^+]*\)+.*;\1;'
But the returned value is 33596 ...
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 08:16 PM
12-04-2003 08:16 PM
Re: find and cp -p
I got the output using expr "`cat a51290TOPSMAL01out`" : ".*BGM+12E::9+\(.*\)+6'DTM+137.*"
I have about 500 files of a*out in that folder, so to run thru all files, what should I do in a better way?
Usually what I'do would be:-
#! /bin/ksh
ls file* >> file.lis
exec 3< file.lis
while read line <& 3
do
expr "`cat $line`" : ".*BGM+12E::9+\(.*\)+6'DTM+137.*" >> output.txt
done
Is there any better way? Sorry...I'm a newbie but like to learn....;-)
thanks again
Zul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 08:19 PM
12-04-2003 08:19 PM
Re: find and cp -p
grep BGM file* | sed 's;.*BGM+[^+]*+\([^+]*\)+.*;\1;'
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 08:26 PM
12-04-2003 08:26 PM
Re: find and cp -p
cat file* | grep BGM | sed 's|BGM+12E::9+\(.*.\)+6\'DTM+137.*|\1' >> output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 08:30 PM
12-04-2003 08:30 PM
Re: find and cp -p
for i in a*out
do
expr "`cat $i`" : ".*BGM+12E::9+\(.*\)+6'DTM+137.*" >> output.txt
done
or try Jean-Louis' option (above)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 09:57 PM
12-04-2003 09:57 PM
Re: find and cp -p
Many many thanks for the help. (I'm almost there!!..yippee)
Now I got a new request from the pointy head boss to find all files created from ie
12/04/03 0000hrs to 12/05/03 0100hrs, itead of 12/04/03 0000hrs to 12/04/03 2359
I cant think a way to do that except have to create 2 scripts.
May I ask for some suggestions.
best regards,
Zul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2003 10:14 PM
12-04-2003 10:14 PM
Re: find and cp -p
if you create a file, e.g. file_begin with a last mod. time of 12/04/03 00:00 and the file file_end with a last mod. time of 12/05/03 01:00, this should work:
# find
regards,
John K.