Re: Advice on how to approach script
From: Chris F.A. Johnson (c.fa.johnson_at_rogers.com)
Date: 06/21/04
- Previous message: yonderstar: "Re: how to feed stuff into telnet program ?"
- In reply to: Paddy: "Re: Advice on how to approach script"
- Next in thread: foo: "Re: Advice on how to approach script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 21 Jun 2004 02:59:51 GMT
On 2004-06-21, Paddy wrote:
>
> Chris F.A. Johnson wrote:
>> On 2004-06-20, Paddy wrote:
>>
>>>Hello
>>>
>>>For some I am sure this may be a basic question. But I need to read a
>>>text files which contains device mac addresses in format below:
>>>
>>> 0009.288f.778a
>>> 0009.23a3.a342
>>>
>>>And change it to:
>>>
>>> 00:09:28:8f:77:8a
>>> 00:09:23:a3:a3:42
>>>
>>>What is the approach you would use to read in the file containing the
>>>MAC addresses and create a new file with the different format?
>>
>>
>> while IFS=. read a b c
>> do
>> echo "${a%??}:${a#??}:${b%??}:${b#??}:${c%??}:${c#??}"
>> done < FILE
[ please don't top post ]
>
> Variables a, b & c now store four digits of the mac address. However, I
> get a bad substitution error when I try to display the first 2 digits.
>
> echo "${a%??}"
>
> Can you see anything wrong with the syntax?
It looks all right -- unless you are not using a POSIX shell.
--
Chris F.A. Johnson http://cfaj.freeshell.org/shell
===================================================================
My code (if any) in this post is copyright 2004, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
- Previous message: yonderstar: "Re: how to feed stuff into telnet program ?"
- In reply to: Paddy: "Re: Advice on how to approach script"
- Next in thread: foo: "Re: Advice on how to approach script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|