LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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
 
LinkBack Search this Thread
Old 08-08-2003, 09:40 AM   #1
parker
LQ Newbie
 
Registered: Aug 2003
Posts: 10

Rep: Reputation: 0
need help substituting with sed


Hai!

I'd like to reformat a MAC address like this:

from
xx-xx-xx-xx-xx-xx
to
xxxxxxxxxxxx

I tried the following which doesn't work unfortunately ;-(

MAC=00-09-6B-E1-77-C6
echo "MAC: "$MAC

MAC2='echo $MAC | sed -e s/-/ /g'
echo "MAC2: "$MAC2
exit

I don't think that it is necessary to point out that i'm a bloody newbie to this...

TIA, Parker
 
Old 08-08-2003, 09:53 AM   #2
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 50
the problem isnt your sed its your shell scripting. if your just typing this at the command prompt then to set a variable you have to export it eg:

export MAC=00-09-6b-e1-77-c6

then echo $MAC works fine, if your in a shell script then you dont need export

then to set MAC2

export MAC2=`echo $MAC | sed -e 's/-//g'`

i would like to explain more but my sausages are about to burn, check out some of the bash howto's on tldp.org
 
Old 08-08-2003, 10:03 AM   #3
parker
LQ Newbie
 
Registered: Aug 2003
Posts: 10

Original Poster
Rep: Reputation: 0
Thnx, that's it!
export MAC2=`echo $MAC | sed -e 's/-//g'`
works fine


may your sausages taste perfect *g*
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sed and escaping & in something like: echo $y | sed 's/&/_/g' prx Programming 7 02-03-2005 11:00 PM
Sed q? ky-lab_rat Linux - Software 5 10-26-2004 07:59 AM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM
help with sed DavidPhillips Programming 3 08-11-2003 04:46 PM
sed.... BongFish Linux - Software 4 08-07-2003 09:24 AM


All times are GMT -5. The time now is 07:30 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration