![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 |
|
||||
|
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. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|