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
How to replace characters 7 through 14 of every line in a file jakSun8 Shell Programming and Scripting 9 12-13-2007 02:13 AM
Replace Characters... lgardner17325 UNIX for Dummies Questions & Answers 8 10-26-2006 05:04 PM
Replace Special characters in a file solai UNIX for Dummies Questions & Answers 1 07-13-2006 10:36 AM
Replace characters in a string using their ascii value roops Shell Programming and Scripting 2 03-04-2005 01:51 AM
how to replace control characters using sed? hillxy Shell Programming and Scripting 5 10-16-2003 10:12 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 01-29-2008
arndorff arndorff is offline
Registered User
  
 

Join Date: May 2006
Posts: 3
Want to replace characters

Hi

I have searched for a way to replace odd characters in a FOLDER NAME. All search-and-replace issues I have seen, only involves how to make search-and-replace on a FILE och with TEXT INSIDE a FILE. My problem is with the FOLDER NAME.

My case is this:
I have a couple of persons that every now and then uploads files that are contained in a folder. Sometimes the foldernames get screwed up resulting in odd characters such as ^,§,√,≈ and so forth, i.e.

G^ran_F_080122

I would like to replace that "^" to an "o" and get

Goran_F_080122

How do I accomplish that?

-Arndorff
  #2 (permalink)  
Old 01-29-2008
anchal_khare anchal_khare is offline
Registered User
  
 

Join Date: Jun 2007
Location: Mumbai,India
Posts: 325
use ascii transfer mode while ftp'ng ur files...

for replacing.. sed 's/\^/o/g' file


Anchal.
  #3 (permalink)  
Old 01-29-2008
arndorff arndorff is offline
Registered User
  
 

Join Date: May 2006
Posts: 3
Quote:
Originally Posted by anchal_khare View Post
use ascii transfer mode while ftp'ng ur files...

for replacing.. sed 's/\^/o/g' file


Anchal.
Thankyou for the quick answer.

However, I am a newbie in shellscripting.
Could you please explain it in more details, I would be happy

Thanks
-Arndorff
  #4 (permalink)  
Old 01-29-2008
anchal_khare anchal_khare is offline
Registered User
  
 

Join Date: Jun 2007
Location: Mumbai,India
Posts: 325
sure.. my pleasure ...
this is sed (stream editor) systex....
general syntec is s/what_to_find/from_what_to_replace/g


the value betweek the slashes may be a text/string or any regular expression ( google it if u dont know about this)

so since ^ has an special mening in regex.. s i escaped it with \.

Hope its clear...

Anchal
  #5 (permalink)  
Old 01-29-2008
arndorff arndorff is offline
Registered User
  
 

Join Date: May 2006
Posts: 3
Quote:
Originally Posted by anchal_khare View Post
sure.. my pleasure ...
this is sed (stream editor) systex....
general syntec is s/what_to_find/from_what_to_replace/g


the value betweek the slashes may be a text/string or any regular expression ( google it if u dont know about this)

so since ^ has an special mening in regex.. s i escaped it with \.

Hope its clear...

Anchal

OK, but am I not supposed to write a loop or echo folder statement? How should I write that?

Thanks in advance
-Arndorff
  #6 (permalink)  
Old 01-29-2008
earnstaf earnstaf is offline
Registered User
  
 

Join Date: May 2007
Posts: 113
Quote:
Originally Posted by arndorff View Post
OK, but am I not supposed to write a loop or echo folder statement? How should I write that?

Thanks in advance
-Arndorff
I imagine you could just copy the name of the directory then do
Code:
mv (paste folder name) newfoldername
In your case,
Code:
mv G^ran_F_080122 Goran_F_080122
Escape characters ( \ ) as necessary.
Sponsored Links
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 06:33 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