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
rename multiple filename.45267.txt to >> filename.txt jason7 Shell Programming and Scripting 6 01-29-2009 05:37 PM
sed-question delete everthing after a couple of numbers mcW Shell Programming and Scripting 2 10-22-2008 01:13 PM
script to change filename with numbers silversurfer202 Shell Programming and Scripting 5 11-10-2006 10:13 AM
Delete filename with month -2 dstinsman UNIX for Dummies Questions & Answers 1 02-14-2006 01:16 PM
Stupid filename - can't delete it sTorm UNIX for Dummies Questions & Answers 4 06-20-2002 01:04 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-12-2009
villain41 villain41 is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 29
delete numbers in a filename

I have some files where numbers are part of like
eg 1add1.txt
23sub41.txt etc

I want to remove numbers from the filenames(whereever it may be).

I used echo `ls *.txt | sed -e "s/[0-9]//"`

But its removing first digits like 1add1.txt becomes add1.txt

My intention is to make 1add1.txt to add.txt

ANy scripts
  #2 (permalink)  
Old 02-12-2009
subin_bala subin_bala is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 57
try this

ls *.txt | sed -e "s/[0-9]//g"
  #3 (permalink)  
Old 02-12-2009
rakeshou rakeshou is offline
Registered User
  
 

Join Date: May 2007
Posts: 75
Quote:
Originally Posted by subin_bala View Post
try this

ls *.txt | sed -e "s/[0-9]//g"
the "g" in above sed command tells sed to match all occurrences
  #4 (permalink)  
Old 02-12-2009
villain41 villain41 is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 29
the solution is working perfectly, thanks for the explanation of that also.
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 11:49 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