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
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
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
2. UNIX for Dummies Questions & Answers
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
3. Shell Programming and Scripting
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
4. Shell Programming and Scripting
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
5. Shell Programming and Scripting
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
6. Shell Programming and Scripting
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
7. Shell Programming and Scripting
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
8. UNIX for Dummies Questions & Answers
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
9. Shell Programming and Scripting
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
10. Shell Programming and Scripting
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
FPRINTF(3) 1 FPRINTF(3)
fprintf - Write a formatted string to a stream
SYNOPSIS
int fprintf (resource $handle, string $format, [mixed $args], [mixed $...])
DESCRIPTION
Write a string produced according to $format to the stream resource specified by $handle.
PARAMETERS
o $handle
-A file system pointer resource that is typically created using fopen(3).
o $format
- See sprintf(3) for a description of $format.
o $args
-
o $...
-
RETURN VALUES
Returns the length of the string written.
EXAMPLES
Example #1
fprintf(3): zero-padded integers
<?php
if (!($fp = fopen('date.txt', 'w'))) {
return;
}
fprintf($fp, "%04d-%02d-%02d", $year, $month, $day);
// will write the formatted ISO date to date.txt
?>
Example #2
fprintf(3): formatting currency
<?php
if (!($fp = fopen('currency.txt', 'w'))) {
return;
}
$money1 = 68.75;
$money2 = 54.35;
$money = $money1 + $money2;
// echo $money will output "123.1";
$len = fprintf($fp, '%01.2f', $money);
// will write "123.10" to currency.txt
echo "wrote $len bytes to currency.txt";
// use the return value of fprintf to determine how many bytes we wrote
?>
SEE ALSO
printf(3), sprintf(3), sscanf(3), fscanf(3), vsprintf(3), number_format(3).
PHP Documentation Group FPRINTF(3)