The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Need help renaming files bbbngowc UNIX for Dummies Questions & Answers 5 04-23-2008 02:08 PM
Renaming Files abch624 Shell Programming and Scripting 2 03-20-2008 12:54 AM
Renaming files Tygoon UNIX for Dummies Questions & Answers 7 01-06-2008 10:59 PM
renaming files systemsb UNIX for Dummies Questions & Answers 3 05-25-2006 12:56 AM
renaming files raguramtgr UNIX for Dummies Questions & Answers 4 09-21-2004 10:57 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-05-2006
whatsup whatsup is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 2
Renaming files

Hello.

Need to rename 1000's of files with names like 991%20(2003)%20-%20991%20Ryall%20Prison%20Population%20and%20Recorded%20Crime.doc
All I need is the beginning numbers , in this case 991 .

Tried: for file in * ; do mv $file `echo $file | sed '/^[0-9]{p;q}'` ; done

but no luck.

Thank You.
Whatsup.
  #2 (permalink)  
Old 07-05-2006
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,209
You'll find this link very helpful.
  #3 (permalink)  
Old 07-06-2006
crabbie_upk's Avatar
crabbie_upk crabbie_upk is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 18
File system explorer on UNIX/LINUX

Hi,

You might find http://www.computerhope.com/unix/tree.htm usefull for building the file system explorer on UNIX/LINUX.

Thanks,
Uday.
  #4 (permalink)  
Old 07-07-2006
LivinFree's Avatar
LivinFree LivinFree is offline Forum Advisor  
Goober Extraordinaire
  
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
Quote:
Originally Posted by reborg
You'll find this link very helpful.
How was that helpful?

Try this, assuming you're using bash or ksh:
Code:
for f in *; do echo ${f%%\%*}; done
  #5 (permalink)  
Old 07-07-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
That was helpful because the link pointed to the search page, a utility that too few of our members use before asking questions. Many of the questions asked have been answered before, and a search might have provided whatsup with the answer.
  #6 (permalink)  
Old 07-07-2006
LivinFree's Avatar
LivinFree LivinFree is offline Forum Advisor  
Goober Extraordinaire
  
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
Quote:
Originally Posted by blowtorch
That was helpful because the link pointed to the search page, a utility that too few of our members use before asking questions. Many of the questions asked have been answered before, and a search might have provided whatsup with the answer.
I understand what the search function does - I use it myself. However, a user in need of some assistance may not know what search terms to use. Can you at least provide some search terms that may begin to answer the question? My reply took a couple of minutes (including testing to make sure I didn't have syntax issues), and I still didn't give out a complete answer, although enough for someone to figure out one way of doing what they want.

You may as well say "Try 'man bash'". Why even bother responding? Can you find a search string that matches what the user asked?
  #7 (permalink)  
Old 07-09-2006
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,209
Quote:
Originally Posted by macosta
Can you at least provide some search terms that may begin to answer the question?
Search term:
rename files

Returns dozens of examples of examples of this question or others very similar and its possible answers. Most people are quite capable of using a search function, and repeating answers that have been given umpteen times before does not contribute anything to the knowledge base of these forums, however pointing a user to the search engine, may provide them with:
  • The answer to their question
  • The answer to some other question they have
  • A better way of doing something they already do in an inefficient way
  • The knowledge that there is a seach engine on this site

Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
Closed Thread

Bookmarks

Tags
linux

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 03:23 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