The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > HP-UX
Google UNIX.COM


HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How can i copy files by date last modifed range? geauxsaints UNIX for Advanced & Expert Users 4 05-25-2008 08:06 AM
Sorting Files by date and moving files in date order rebel64 Shell Programming and Scripting 2 03-11-2008 08:45 AM
To copy the files newer than specific date RAJESHKANNA SUN Solaris 3 08-07-2007 12:44 AM
script to rename files with current date and copy it. logic0 UNIX for Dummies Questions & Answers 6 05-01-2007 02:13 AM
How to copy a file according to the date Nayanajith Shell Programming and Scripting 1 06-21-2006 12:46 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-10-2006
Registered User
 

Join Date: Aug 2005
Posts: 75
Stumble this Post!
copy files with date

Hi,

I have a coupel of files in /tmp which I have to copy to /var. But I want their name to be same as the source with date suffix.

But the problem is I don;t know the prefix of the file, I only know the suffix of file.

AAA.997
ABC.997
ADC.997

The later part 997 is constant but the former part can be anything.

Is there any way that while making copy, I can find the prefix of file and then copy to /var as AAA.997.0310061430.

Thanks,
Inder
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-10-2006
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,002
Stumble this Post!
Code:
#!/bin/ksh

a='AAA.997'

prefix="${a%%.*}"
suffix="${a##*.}"

echo "a->[${a}] prefix->[${prefix}] suffix->[${suffix}]"
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:09 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0