delete numbers in a filename


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting delete numbers in a filename
# 1  
Old 02-12-2009
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  
Old 02-12-2009
try this

ls *.txt | sed -e "s/[0-9]//g"
# 3  
Old 02-12-2009
Quote:
Originally Posted by subin_bala
try this

ls *.txt | sed -e "s/[0-9]//g"
the "g" in above sed command tells sed to match all occurrences
# 4  
Old 02-12-2009
the solution is working perfectly, thanks for the explanation of that also.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Filter and delete numbers in a list

Hello, I've got a list of a single column numbers like 3000.66 3002.55 3062.23 3242.12 etc... I would like to delete all numbers higher than for example 3060.00 and lower than 2990.00 How can I do that? Thanks in advance (2 Replies)
Discussion started by: Board27
2 Replies

2. Shell Programming and Scripting

Renaming file that has multiple numbers as filename

Hi I have a file with filename as "partition-setup-and-ipl.vtcmd.76217657132.9721536798" Now i need to move this file as "partition-setup-and-ipl.vtcmd.76217657132.9721536798_org" i tried with # ls | grep -E "partition-setup-and-ipl.vtcmd.+"... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

3. UNIX for Dummies Questions & Answers

Urgent_need to delete columns with numbers

Dear all, I have one file (see below) with more then 100 columns, and need only column which has GType in label with Alphabets, please help me to remove this columns with numbers. input file is n.201.GType n-201.Theta n-201.R n_1.GType n_1.Theta n_1.R n_7.GType ... (1 Reply)
Discussion started by: AAWT
1 Replies

4. Shell Programming and Scripting

increase/decrease multiple numbers in a filename.

I got a game that output map tiles of the session with the 0,0 position at the place you login/spawn. That makes making a map somewhat troublesome since the 0,0 will move. So I've been looking for a way to change the numbers in the filenames of all files in a folder by a certain value. The... (5 Replies)
Discussion started by: Ravenholdt
5 Replies

5. Shell Programming and Scripting

how to delete records with the given line numbers

I have a file which has about 10000 records and I need to delete about 50 records from the file. I know line numbers and am using sed '134,1357,......d' filename > new file. It does not seem to be working. Please Advice (5 Replies)
Discussion started by: mad_man12
5 Replies

6. Shell Programming and Scripting

Script to delete text from the end of a filename

Hi all, I am trying to write a script that will delete a certain amount of text from the end of a filename. For example. Input: name of file (more text).pdf Output: name of file.pdf So is it possible to write a script the deletes, in this example twelve (12) digits from the end... (6 Replies)
Discussion started by: Monkey Dean
6 Replies

7. Shell Programming and Scripting

How to remove numbers from filename

Hi all, Can I edit this script: find . -type f | while read i;do && mv "$i" "${i//abc/}" ;done so that it will not only take out abc from the filename but also take out any numbers that might be in the filename as well. An example would be, Input: filename abc 2009.mov Output:... (7 Replies)
Discussion started by: Monkey Dean
7 Replies

8. Shell Programming and Scripting

script to change filename with numbers

ok, this one is definitely too hard for my shell-script-skills. Hopefully, there is somebody who can help me with this: I have a folder with files in it named 0.ppm 10.ppm 2.ppm ... 5.ppm 50.ppm 55.ppm ... 355.ppm 360.ppm etc. As you will notice, the order in which the files are... (5 Replies)
Discussion started by: silversurfer202
5 Replies

9. UNIX for Dummies Questions & Answers

Delete filename with month -2

KSH - I've got a script that is generating a number of log files like this: y=`date +"%y"` m=`date +"%m"` $LOG_DIR/tuscprof_tbl_$y$m.log I only want to keep the current 2 months' worth of files (current month and prior month). So I'm trying to come up with a way to delete any that... (1 Reply)
Discussion started by: dstinsman
1 Replies

10. UNIX for Dummies Questions & Answers

Stupid filename - can't delete it

I have created a file with a stupid filename with a perl script, and now I can't delete it. The file's called -s-c.log. When I try to delete it, I get that: <>/home/ahi $ rm -s-c.log UX:rm: ERROR: Illegal option -- s UX:rm: ERROR: Illegal option -- - UX:rm: ERROR: Illegal option -- c UX:rm:... (4 Replies)
Discussion started by: sTorm
4 Replies
Login or Register to Ask a Question