Find the answer to your Linux question:
Results 1 to 4 of 4
Hi there, I'm new to the forums, been supporting various linux machines for a couple of years and usually use simple scripts for basic tasks. Recently I have been asked ...
  1. #1
    Just Joined!
    Join Date
    Nov 2008
    Posts
    5

    when not to script? (please forgive my noobishness)

    Hi there,

    I'm new to the forums, been supporting various linux machines for a couple of years and usually use simple scripts for basic tasks. Recently I have been asked to create a script that goes and finds a whole bunch of .log and .txt files, searches them for a selection of values and returns an associated value (which has 3 possible conitations) which is then used to search on another file and return associated values from both searches into the same file. At the same time as that I need to get the extract part of the file path (/country/serialnumber) and use that as a label at the beggining of the line of returned values.

    Does that make sense to anyone out there? The only reason a script is being requested I think is because someone doesn't want to go through the 250+ sub-folders (all of which contain 1 interface.log or interface.txt file and 1 config.log or config.txt file) and extract the information manually.

    At the moment I can grep the files within the individual sub-folder and get the values I want out but it's very messy unfortunately:

    grep -B 1 eth interface.* >interfacereport.txt

    which gives me everything I want plus the above line for labels, plus a lot of gumf I don't need (which I haven't gone to the trouble of pasting in but will if someone thinks it might help) like so:

    Name IP Address Zone
    eth1 10.48.96.1/24 Trust

    Anyway - I'm not sure if this will make sense to anyone else but I hope someone out there can make heads or tails of it!

    Many thanks! (I apologise if this is a dumb question btw)

  2. #2
    Just Joined!
    Join Date
    Nov 2008
    Posts
    5
    hmm, maybe I phrased the question badly; ah well - I can't get my head around this

  3. #3
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    Make a couple of test data files with a few lines each.

    Write a toy script which starts to do what you think you might want.

    Look at the output and tell yourself, "No, that's not exactly what I had in mind."

    Play with the script to make the output closer to what you want.

    Introduce a few more lines of test data. The new test data should test unusual cases of data, if you can think of any.

    Rinse. Repeat. Come back here if you have specific questions.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  4. #4
    Just Joined!
    Join Date
    Nov 2008
    Posts
    5
    thanks - I'll keep playing with my script in the way you suggest; I hope I get somewhere soon, my fingers are getting tired

Posting Permissions

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