- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Set file timestamp using informations of another f...
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
02-08-2017 04:25 AM - edited 02-08-2017 05:32 AM
02-08-2017 04:25 AM - edited 02-08-2017 05:32 AM
Hi,
I have two files file1 and file2 like this.
ls -lrt file*
Feb 7 16:01 file1.log
Feb 8 13:23 file2.txt
I want to script something able to set file2 timestamp with file1 information to have this.
ls -lrt file*
Feb 7 16:01 file1.log
Feb 7 16:01 file2.txt
is touch -r file1 file2 is well enough ?
Any ideas ?
kind regards, Den.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2017 05:36 AM
02-08-2017 05:36 AM
Re: Set file timestamp using informations of another file
> [...] set file2 timestamp with file1 information [...]
man touch
The big problem is parsing the "ls" output, and putting it into the
format required by "touch". GNU "ls" has more date-time format options,
which might be more helpful than the usual HP-UX "ls".
I'd probably look at writing a C program before trying to deal with
old-style "ls" output.
man stat
man utime
Note that this is almost trivially easy on a VMS system, where
there's a standard date-time format, which is used for input and output
by nearly all common facilities.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2017 05:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2017 07:16 AM - edited 02-08-2017 07:24 AM
02-08-2017 07:16 AM - edited 02-08-2017 07:24 AM
Re: Set file timestamp using informations of another file
Hi,
thanks for your answer.Very appreciated.
Do you mean I could use some other flags to store all timestamp attributes (Access time, Modification time) ?
I have tried to find the syntax the combined syntax for -r -a -m but I did not find it.
Kind regards, Den.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2017 07:30 AM
02-08-2017 07:30 AM
Re: Set file timestamp using informations of another file
Hi,
How to have the same information after the touch -r for the file named aa..log ??
ORASIET2[root]/tmp # touch -r cfgvg.out aa.log
ORASIET2[root]/tmp # istat cfgvg.out
Inode 12 on device 10/7 File
Protection: rw-r--r--
Owner: 0(root) Group: 0(system)
Link count: 1 Length 75 bytes
Last updated: Tue Oct 18 10:19:48 2016
Last modified: Tue Oct 18 10:19:48 2016
Last accessed: Sun Feb 5 17:12:21 2017
ORASIET2[root]/tmp # istat aa.log
Inode 21 on device 10/7 File
Protection: rw-r--r--
Owner: 0(root) Group: 0(system)
Link count: 1 Length 0 bytes
Last updated: Wed Feb 8 16:28:55 2017
Last modified: Tue Oct 18 10:19:48 2016
Last accessed: Sun Feb 5 17:12:21 2017
Kind regards,
Den.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2017 11:32 PM
02-11-2017 11:32 PM
Re: Set file timestamp using informations of another file
>I have tried to find the syntax the combined syntax for -r -a -m but I did not find it.
It's the obvious: touch -am -r ref_file file_name ...