Forums Register Login

how to copy a file to a different location with a part of the file name as the filename

+Pie Number of slices to send: Send
I have set of files residing in my hone directory in different naming conventions as shown below,

ap_aearo_prod.20091104044210.Z.20091106.212217
ap_boise_prod.20091029064716_sorted.Z.20091106.212201
ap_boise_prod.20091029064716.Z.20091106.212158
arms_820i_prod.000003ywS.Z.20091109.064508

I wanted to copy these files to a different location with the filename being only till the "Z" i.e.; this file ap_aearo_prod.20091104044210.Z.20091106.212217 has to be copied as ap_aearo_prod.20091104044210.Z, have to truncate the part after the Z.

I have set of files under this directory. This set of files can be identified by the combination of ap_*_prod*20091106* as I need only these files from this datestamp, I have unwanted files with the same datestamp as well.

Can anyone advise
+Pie Number of slices to send: Send
I tried below code on your mentioned files. Give it a try.




PS : Script was in same directory where files are. Customise it
+Pie Number of slices to send: Send
Sorry I forgot to mention that I need the script in UNIX. I am sorry for that
+Pie Number of slices to send: Send
It's perl script and ran it on linux/unix
+Pie Number of slices to send: Send
when you say in your code as <*>, I beleive it will pick all the files under that directory but I want only the files matching as I have explained above
+Pie Number of slices to send: Send


this to



This will take only those files starting with ap_

Hope this helps now

+Pie Number of slices to send: Send
create a local script

chmod a+x adhoc.sh, and

+Pie Number of slices to send: Send
It worked. Thanks
I wish to win the lottery. I wish for a lovely piece of pie. And I wish for a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1255 times.
Similar Threads
policy file
how to insert header
how to copy files at runtime
JSP URL encoding
tomcat "logging.properties"
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:53:02.