The UNIX and Linux Forums  


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
Script to rename files cpreovol Shell Programming and Scripting 3 04-01-2008 12:45 PM
Script to rename files Dinkster UNIX for Dummies Questions & Answers 5 01-22-2008 08:55 AM
script to rename files with current date and copy it. logic0 UNIX for Dummies Questions & Answers 6 05-01-2007 06:13 AM
copy and rename list of files kinmak UNIX for Dummies Questions & Answers 7 02-27-2005 09:23 PM
Rename Files with a script ? yoveln OS X (Apple) 1 02-08-2004 12:45 PM

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

Join Date: Sep 2006
Posts: 209
please help - script to list and rename

Hi Friend,

I have a small script to list all file FFAAAAABBBBB00001 and FFAAAAABBBBB00001.repaired (when I run another script, the orginal file will output another *.repaired file) in my unix directory, and reaname the output file FFAAAAABBBBB00001.repaired back to FFAAAABBBBB00001. However, it have some strange message below:

mv: illegal option -- r
mv: illegal option -- w
mv: illegal option -- x
mv: illegal option -- r

The script is:
echo Please input firstcodelist:
read firstcodlist
for filename in `ll FF$firstcodelist*`
do
mv $filename `echo $filename | cut -c 1-17`
done


can you help to modify or any other new good script for me?

Thank you all!!!
  #2 (permalink)  
Old 10-04-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Hi happyv,
You are using the 'll' command, which will give you a long listing. For example, if you run 'll a.out', then your output will be

Code:
-rwxrwxr-x   1 root     other       6532 Sep 15 11:54 a.out

When you cut the first 17 characters from this, what you get is

Code:
-rwxrwxr-x   1 ro

.

Instead of ll, use the ls command. This will just output the filenames and your cut command will get the 17 column filename correctly.
  #3 (permalink)  
Old 10-04-2006
happyv happyv is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 209
thank you.
Closed Thread

Bookmarks

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 02:08 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