Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 08-08-2003, 09:40 AM   #1
LQ Newbie
Registered: Aug 2003
Posts: 10

Rep: Reputation: 0
need help substituting with sed


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


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

echo "MAC: "$MAC

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

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
Senior Member
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
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
Old 08-08-2003, 10:03 AM   #3
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*


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
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 > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:48 PM.

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