Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Remove character "-" in a selected range of file names within a directory

Posted on 2005-03-10
5
Medium Priority
?
275 Views
Last Modified: 2010-08-05
Is there an easy way to remove the character "-" from the files below using sed other unix command?:

1-58284-000-8.gif
1-58284-001-6.gif
1-58284-002-4.gif
1-58284-003-2.gif
1-86156-313-2.gif
1-86156-383-3.gif

1582840008.gif
1582840016.gif
1582840024.gif
1582840032.gif
1861563132.gif
1861563833.gif

Thanks,

David



0
Comment
Question by:dpaule
3 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 200 total points
ID: 13513643
for i in *.gif
do
   mv $i `echo $i | sed 's/-//g'`
done
0
 
LVL 38

Expert Comment

by:yuzh
ID: 13514026
You can also use "tr" to do the job:

for i in *.gif
do
   mv $i `echo $i | tr -d "-"`
done
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 13515753
guessing ...
  perl -e'for(@ARGV){($f=$_)=~s(-)()g;print "rename $_,$f";}'
and if that is what you want, then use
  perl -e'for(@ARGV){($f=$_)=~s(-)()g;rename $_,$f;}'
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses
Course of the Month11 days, 14 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question