Find the answer to your Linux question:
Results 1 to 5 of 5
hi all, can any one help with writting a unix script that knows to pull out from a file a string and retype it to a new file. the string ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2007
    Posts
    27

    Post Need help with beginners unix script


    hi all,
    can any one help with writting a unix script that knows to pull out from a file a string and retype it to a new file.
    the string could appear in the file with a different value but its structure is the same (for example: "1A:CB:43:8D"), and the position of it in the line is always in the same place.
    after the new file will be created, another function should go over it, and calculate and print the number of appearance of each string.

    i will appreciate your help

  2. #2
    Linux User
    Join Date
    Aug 2006
    Location
    Croydon, PA
    Posts
    392
    I guess this should have been posted in the "Scritps" section but any who...
    Need more info like a partial of the file you are getting te info from.
    Good Luck,
    Ski
    RHCT

  3. #3
    Just Joined!
    Join Date
    Jan 2007
    Posts
    27

    Unhappy

    dear ski
    "I guess this should have been posted in the "Scritps" section but any who..."
    U mentioned it should be posted in scripts section. I don't know about the scripts section.

    Need more info like a partial of the file you are getting te info from.

    What u need more info ??

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Newbie
    Join Date
    Jan 2007
    Location
    Cupertino, CA
    Posts
    157
    Are you trying to get the forum to help with your college assignments?

    Anyway, grep is the command you are looking for. Try to build a script around it. Following is an example...

    #!/bin/sh
    fname=$1

    grep ".{99}[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]" $fname | wc -w


    will do what you asked for (assuming at 100th position in the file) without an intermediate file. (I have not tested this, but you can play with it until you get it right).

    Suggest to get a good book on Regular Expressions or simply read man pages for grep, regex(7), perlre etc...

  6. #5
    Just Joined!
    Join Date
    Jan 2007
    Posts
    27

    Smile

    Thanks for you reply,
    ha ha ha
    For your information I am not a student to do my assingment. My hobby is to learn Linux. I used to get the help of my friends / forums.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •