The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Operating Systems > AIX
.
google unix.com



AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
parse an arpwatch file and retain most recent mac CM64 Shell Programming and Scripting 8 04-12-2007 01:21 AM
Get the most recent file from a remote server anujairaj UNIX for Dummies Questions & Answers 5 09-27-2006 11:31 AM
getting the most recent file anujairaj Shell Programming and Scripting 3 06-22-2006 04:34 PM
reading directory for most recent file? duncan_glover UNIX for Dummies Questions & Answers 3 08-22-2002 08:26 AM
Most Recent File script josborn777 Shell Programming and Scripting 1 03-29-2002 05:01 PM

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 02-15-2006
warpmail warpmail is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 1
Changing name of most recent file

I need to change the name of a file within a script. For example I have two files. The first named scrnslc_0001 and the second scrnslc_0002. I want to change the name of the second to scrnslc_out. The appended number will change, and I won't know the file name in advance. If there were only one file I could use:
mv -f scrnsl* scrnslc_out
We're on AIX 5.2

Thanks
  #2 (permalink)  
Old 02-15-2006
hegemaro hegemaro is offline
Registered User
  
 

Join Date: Feb 2006
Location: Schenectady, NY
Posts: 134
Admittedly I do not fully understand the problem but you can narrow your ls search from a '*' wildcard to specific numbers.

ls scrnslc_[0-9][0-9][0-9][0-9]

The ls command sorts alphabetically by default so if you're looking for the last file to move you can pipe the output of the above into a tail -1. The whole thing put together might look something like this:

mv `ls scrnslc_[0-9][0-9][0-9][0-9] | tail -1` scrnslc_out

If you want to save the scrnslc_#### files as they are, you could use the ln command in stead of mv.

I hope this is helpful.
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:04 AM.


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