The UNIX and Linux Forums  


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
cut a part of the file kurosaki Shell Programming and Scripting 1 06-02-2008 10:14 AM
remove part of a line tiger99 Shell Programming and Scripting 16 02-06-2008 08:29 AM
Remove part of the file chiru_h Shell Programming and Scripting 10 08-22-2007 05:15 PM
How do I take out(remove) the date part in the file name? ruthless HP-UX 5 02-06-2006 01:32 PM
Help with multiple file rename - change case of part of file name steve7 UNIX for Dummies Questions & Answers 7 06-30-2005 02:41 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 11-27-2006
braindrain braindrain is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 67
remove certain part of file name

Hi,
Is it possible to remove the first part of the file name using find.

i.e i have something like 2006abc.txt , 1007bed.txt etc,
I wanna rename them to abc.txt , bed.txt

I tried some stupid way..

find . -name '*.txt' -exec mv {} `cut -f2-5 -d"_" {}` \;

somehow iam not getting it.

appreciate any help.
  #2 (permalink)  
Old 11-27-2006
ziminski ziminski is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 5
not tested but how about like this:
find . -name '*.txt' | `expr substr {} 5 9`|mv {}.txt
Where 5 is starting position and 9 is the number of chacters after the starting position.
  #3 (permalink)  
Old 11-27-2006
ranj@chn ranj@chn is offline Forum Advisor  
Playing with Ubuntu Now!
  
 

Join Date: Oct 2005
Location: Chennai
Posts: 365
how about this


Code:
for fname in *.txt
do
mv $fname ${fname##*[0-9]}
done

  #4 (permalink)  
Old 11-28-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958

Code:
find . -maxdepth 1 -name '*.txt' -print -exec echo "mv {} \`echo {} | sed 's/[^a-z.]//g'\`" \; | zsh

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 04:41 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