LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-11-2006, 11:27 AM   #1
lecontel
LQ Newbie
 
Registered: Aug 2006
Posts: 1

Rep: Reputation: 0
Angry Transform \\psds0t01\c$ to psds0t01_c


Hello,

I want to transform in a file a string in form
\\[a-z]|[A-Z]|[0-9]\[a|z]$

For example:
\\psds0t01\c$ to psds0t01_c
\\CCR478e0\z$ to CCR478e0_z

I try :

extract the string in a variable and use tr
but \c cause probleme, but \d is good

use sed directly from the file gives same bad result

Thank you for help
 
Old 08-11-2006, 11:48 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Using sed:

sed -e 's/^[\]*//' -e 's/\$$//' -e 's/\\/_/' infile

infile contains:

\\psds0t01\c$
psds0t01_c
\\CCR478e0\z$
CCR478e0_z

Test run:

$ sed -e 's/^[\]*//' -e 's/\$$//' -e 's/\\/_/' infile
psds0t01_c
psds0t01_c
CCR478e0_z
CCR478e0_z

Hope this helps.

Last edited by druuna; 08-11-2006 at 12:41 PM.
 
Old 08-11-2006, 11:49 AM   #3
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
s/^\\// - If the first chzracte is a backslash, then convert it to nothing.
s/\\/\_/ - If a back slash, then substitute it with an underscore.
s/$\$// - If the last characte is a $, then then convert it to nothing.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
transform install DVD in CD's komar Linux - Laptop and Netbook 1 04-18-2006 09:18 AM
No accelerated IMDCT transform found Nay_Nay Linux - Newbie 0 02-17-2006 08:32 AM
how to transform ip -> name cristi1979 Linux - Networking 14 06-16-2003 01:43 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration