The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Comparing filename-substrings and remove unnecessary files cypher82 UNIX for Dummies Questions & Answers 5 06-06-2008 01:26 AM
Remove path from filename borgeh UNIX for Dummies Questions & Answers 3 08-23-2007 07:58 AM
Use same filename for prefix in the split command namityadav UNIX for Dummies Questions & Answers 1 07-25-2006 01:24 PM
Remove prefix from filenames HLee1981 Shell Programming and Scripting 6 01-25-2006 11:57 AM
remove pound sign from filename kristy UNIX for Dummies Questions & Answers 4 02-13-2002 11:31 AM

Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-10-2002
Registered User
 

Join Date: Nov 2001
Location: New Zealand
Posts: 333
remove filename prefix

I've got a bunch of files called oldabc, olddef etc.

i want to copy these to be abc, def....

I can do this with file extensions....but can get the logic to work for prefixes. All the files I am interested in have a prefix of 'old'.

This loop is no good for me....it looks at the content of the files...rather than changing the filename.

for files in `ls *fmt`;
do
newfilename="cut -c4-50 $files";
cp $files $newfilename;
done

How do I get it to look at the filename and change it - rather than the content of the file?
__________________
Pete
Forum Sponsor
  #2 (permalink)  
Old 07-10-2002
Registered User
 

Join Date: Jul 2002
Location: void
Posts: 53
>for files in `ls *fmt`;
>do
newfilename="cut -c4-50 $files>";
>cp $files $newfilename;
>done

Code:
for files in `ls *fmt`
do
newfilename=`echo $files | cut -c4-`
cp $files $newfilename
done

Last edited by hell666; 07-11-2002 at 06:15 AM.
  #3 (permalink)  
Old 07-10-2002
Registered User
 

Join Date: Nov 2001
Location: New Zealand
Posts: 333
ahhhh - echo...of course...great thanks.
__________________
Pete
Google UNIX.COM
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:45 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