- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to rename file
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
Discussions
Discussions
Forums
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
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
тАО02-17-2011 08:22 PM
тАО02-17-2011 08:22 PM
I need to rename file to 'file_name_sysdate'. Because everyday one log file generates in the same directory and rewrites previous one. I need to have all of log files during 2-3 weeks. Log files cant be generated with unique name(pity but it's software feature). Always the same
File generates once a day in midnight, and i want to rename this file in the morning to
Regards,
Rustam
Solved! Go to Solution.
- Tags:
- mv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2011 08:48 PM
тАО02-17-2011 08:48 PM
Re: How to rename file
mv file_name.log file_name_$(date +%m%d%Y).log
This would yield a file with a name like file_name_02172011.log
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2011 09:15 PM
тАО02-17-2011 09:15 PM
Re: How to rename file
I couldnt run your syntax in bash environment. I run and got error:
$ mv file_name.log file_name_$(date+%m%d%Y).log
-bash: date+%m%d%Y: command not found
how can i explain to bash date+%m%d%Y?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2011 10:56 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2011 10:59 PM
тАО02-17-2011 10:59 PM
Re: How to rename file
You missed a space:
# date+%m%d%Y
-bash: date+%m%d%Y: command not found
# date +%m%d%Y
02182011
So add the missing space and it will work!
sangilak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-18-2011 05:00 AM
тАО02-18-2011 05:00 AM
Re: How to rename file
>
> This would yield a file with a name like
> file_name_02172011.log
And if you use something like "_%Y-%m-%d"
instead, then you might get names which will
be easier to read and which will sort in the
normal order.
Just a thought.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-20-2011 10:12 PM
тАО02-20-2011 10:12 PM
Re: How to rename file
Regards,
Rustam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-20-2011 11:57 PM
тАО02-20-2011 11:57 PM
Re: How to rename file
be aware, that the percent sign "%" has a special meaning in crontab entries, so it needs an esacpe character.
It may be
date +\%Y ...
or
date +%%Y ...
depending on the OS version you use - look at the man page.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2011 02:31 AM
тАО02-21-2011 02:31 AM
Re: How to rename file
so if i want to use in crontab i must change my script to something like this?:
mv my_file.log my_file_$(date +%%m%d%Y).log
My OS version is 11.3
regards,
rustam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2011 10:51 AM
тАО02-21-2011 10:51 AM
Re: How to rename file
You must quote each %:
mv my_file.log my_file_$(date +\%m\%d\%Y).log