#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    1
    Rep Power
    0

    Unix Admin Awk/Sed script, need some help! =)


    Good afternoon everyone! I work as a system administrator as a consultant. I help administrate a polling program for a number of stores.

    I have a list of store numbers that's called by a script (4000+ store numbers), I need to comment out 300 store numbers from that list. Is there an easy script that could compare the two and comment out specific numbers while preserving the old list? They are not consecutive numbers either, and they must remain commented (not deleted).

    Sorry if I posted this in the wrong section, I really appreciate any help

    -Mike
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,449
    Rep Power
    1751
    Make a backup copy of the original file first, but being an admin you'd be doing that anyway. Right?
    Is the list of store numbers to be commented out available in a handy file? If so, you should be able to throw together a quick awk script that parses the original file and, based on the return of a user function output the original line or the original line commented out. The user function would take the store number as a parameter and use that in a system() call to a grep command (use -c or -q options) for this number in the list of numbers to be commented out.
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc

IMN logo majestic logo threadwatch logo seochat tools logo