The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Retain Only specific number of file in Directory ranvijaidba UNIX for Advanced & Expert Users 2 01-05-2009 06:47 AM
Retain file permissions when saving .sh file from internet [OS X] baza210 Shell Programming and Scripting 4 12-11-2008 10:18 AM
How to retain the header information of a file ahjiefreak UNIX for Dummies Questions & Answers 0 12-04-2007 07:21 PM
How to retain file permissions during FTP on Solaris 5.9 ? gauravsachan UNIX for Advanced & Expert Users 3 04-26-2007 11:19 AM
parse an arpwatch file and retain most recent mac CM64 Shell Programming and Scripting 8 04-12-2007 01:21 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-18-2009
scotbuff scotbuff is offline
Registered User
  
 

Join Date: Jun 2005
Location: Middletown, PA
Posts: 73
Retain File Timestamp

There are directories of files that I have to run the dos2ux command on to get ride of the carriage return characters. Easy enough, but I have to retain the original timestamps on the files. I am thinking that I am going to have to strip off the timestamp for each file and convert it to unix time and then run touch against each file after recreating the file with dos2ux. This is probably as clear as mud, but does anyone have any elegant ideas for accomplishing this?

I am planning to loop through the listing but my elegance lags when I try am trying to figure out the best way to do the conversion. Or am I missing some tool available on HP-UX that will not alter the timestamp but will remove the ^M from the end of every line? Thanks in advance.
  #2 (permalink)  
Old 03-18-2009
methyl methyl is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1,175
If your unix has "touch -r <reference file> filename" is is fairly easy to "cp -p" the original file to preserve the file modification timestamp then edit the original file and restore the file modification timestamp with "touch -r". This method will not retain the file creation timestamp.
  #3 (permalink)  
Old 03-18-2009
scotbuff scotbuff is offline
Registered User
  
 

Join Date: Jun 2005
Location: Middletown, PA
Posts: 73
The touch -r is the ticket. I was unfamiliar with that flag and it works perferctly within a loop while converting the files to unix format. Thanks so much!
  #4 (permalink)  
Old 03-18-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,762
file ctime == file inode time - there is no standard file creation time for UNIX files
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:26 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0