Re: Advice on how to approach script

From: Chris F.A. Johnson (c.fa.johnson_at_rogers.com)
Date: 06/21/04

  • Next message: William Park: "Shell project announcements"
    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
    

  • Next message: William Park: "Shell project announcements"

    Relevant Pages

    • Re: How to extract all but one file from a tar archive?
      ... but my partition is not large anough to store all files ... "Chris F.A. Johnson" wrote: ... >> Hallo, ...
      (comp.os.linux.misc)
    • Re: How to extract all but one file from a tar archive?
      ... but my partition is not large anough to store all files ... "Chris F.A. Johnson" wrote: ... >> Hallo, ...
      (comp.unix.misc)
    • Re: Sorting with lines last digit
      ... Chris F.A. Johnson wrote: ... >> Yeah, that can be resolved, but a proposed solution SHOULD have taken ... I said numbers, not digits. ...
      (comp.unix.shell)
    • Re: creating date-based sub-directories
      ... store the directory in a variable so you don't have to call ... My code in this post is copyright 2003, Chris F.A. Johnson ... and may be copied under the terms of the GNU General Public License ...
      (comp.unix.shell)
    • Re: Compare creation time of two files
      ... "Chris F.A. Johnson" writes: ... >> I would like to check the creation time of two files and see if they were ... > First, Unix does not store the creation time of a file, it stores ... May I suggest a slight alteration to your description, Chris? ...
      (comp.unix.shell)