#1
  1. Learning MySQL, PHP & CSS
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2007
    Location
    Powys/Shrops border (UK)
    Posts
    269
    Rep Power
    47

    Help with awk (I think!) SOLVED


    Hi again. I have this code in my shell script but would like to get rid of the rather untidy "if" statement ... I _think_ 'awk' is what I need to be able to read from a plain text file which lists directories NOT to process. Basically doing "if $dirname is not in the text file, then ..." but I can't figure it out or find an example I could hack. Any suggestions are much appreciated.

    Code:
    cd /home
    for dirname in `find -maxdepth 1 -mindepth 1 -type d | sort` ;
    do
    if [ $dirname != "./tech_transfer" -a $dirname != "./transfer" -a $dirname != "./lost+found" ] ; then
    (rest of script...)
    fi
    done
    SOLVED!

    No worries, I found the solution was to use grep, not awk!


    Code:
    if ! grep -q $(basename $dirname) /usr/sbin/dirsize.txt ; then
    Last edited by mikeatvillage; May 5th, 2011 at 05:16 AM. Reason: SOLVED
    It said 'Insert disk #2', but only one will fit.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,450
    Rep Power
    1751
    Nice bit of lateral thinking!

    Comments on this post

    • mikeatvillage agrees : Thanks Simon.
    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