[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Renaming several files at once

Posted on 1998-06-24
8
Medium Priority
?
313 Views
Last Modified: 2011-08-18
I would like to append a .org extension to some files in a directory,
e.g. renaming all files ending with .cc to .cc.org
Now, how can I do that without having to do a :
mv xxx.cc xxx.cc.org  on every file ?
also:
How substitute xxx.cc with xxx.org ?
Im seeking a command+arguments or a minor sh script..
0
Comment
Question by:moonlight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 3

Author Comment

by:moonlight
ID: 2008247
Edited text of question
0
 

Accepted Solution

by:
rayray120497 earned 0 total points
ID: 2008248
try this:

foreach i ( `ls *.cc` )
mv $i $i.org
end

0
 

Expert Comment

by:rayray120497
ID: 2008249

also try this:

foreach i (`ls *.cc` )
set j = `expr $i : '\(.*\).cc'`
mv $i $j
end

0
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!

 

Expert Comment

by:rayray120497
ID: 2008250

sorry, should be

mv $i $j.org
0
 
LVL 3

Author Comment

by:moonlight
ID: 2008251
The first batch didnt work, somehow just one file gets renamed,
but the second did what I wanted, thanx!!
0
 
LVL 3

Author Comment

by:moonlight
ID: 2008252
First one works too now..excellent, thanks again rayray
0
 
LVL 84

Expert Comment

by:ozo
ID: 2008253
 foreach i ( `ls *.cc` )
could be just
  foreach i ( *.cc )

but that's actually a csh command.  
in sh, it would be
  for i in `ls *.cc` ; do
     mv $i $i.org
  done
0
 
LVL 3

Author Comment

by:moonlight
ID: 2008254
thx, ozo.
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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

656 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