- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Moving files to another dir and add the current da...
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
04-29-2002 12:41 AM
04-29-2002 12:41 AM
i'm trying to moving files from one dir to another with a cron job.
In dir /fibu/prod/log/ are some logs saved and numbered from 000 to 999. I want to archive them in a special folder /fibu/arch/ by adding the date in front of the filename.
mv /fibu/prod/log/transferlog.* /fibu/arch/$(date +$y$m$d)*
But so there will be one file (theres today only one in the log dir) moved and renamed to 020429*
Any ideas? Thanks
Patrick
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2002 12:47 AM
04-29-2002 12:47 AM
Re: Moving files to another dir and add the current date
1. Move them.
2. Tar them into one file.
3. Gzip the file and add the date to its name.
HTH
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2002 12:59 AM
04-29-2002 12:59 AM
Re: Moving files to another dir and add the current date
Do you know how i can avoid that a * will be used in the new filename?
Patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2002 01:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2002 01:15 AM
04-29-2002 01:15 AM
Re: Moving files to another dir and add the current date
#!/bin/sh
Source_Dir="/fibu/prod/log"
Dest_DIr="/fibu/arch"
Date_Stamp=`date '+%b-%d-%Y'`
cd $Source_Dir
for index in `ls -l |awk '{print $9}'`
do
mv $index $Dest_DIr/$index.$Date_Stamp
done
-Niraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2002 01:23 AM
04-29-2002 01:23 AM
Re: Moving files to another dir and add the current date
try using a shell script something like this will do it.
#!/usr/bin/ksh
for filename in /fibu/prod/log/transferlog.* ; do
newdate=$(date +%m%d%y)
newfilename=$(print $filename$newdate)
mv $filename $newfilename
done
John.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2002 01:26 AM
04-29-2002 01:26 AM
Re: Moving files to another dir and add the current date
Now it works, thanks a lot.
Patrick