AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.

 View Only
Expand all | Collapse all

have trouble executing the command within script

  • 1.  have trouble executing the command within script

    Posted Tue October 17, 2006 12:27 PM

    Originally posted by: SystemAdmin


    I tested the command it works on command line, but within script it return nothing. I changed the quotation, but no result. Can someone please take a look and let me know.

    [b]textfile="$(ls -al "$directory1" | awk '{print $10}' | grep -v "^ *$" | sort |
    grep -v "./")"[b]
    #text_file="$(ls -al "$directory1" | awk '{print $10}')"
    #textFile=`cat out1.txt`
    echo "$textfile"
    cat out1.txt | while read line
    #for line in "$teixtfile"
    do
    echo "$line"
    find $directory2 -type f -name "$line"
    if $? -eq 0
    then
    diff "$directory1$line" "$directory2$line" > logdiff.out
    case $? in
    0) let "count_same +=1";;
    1) let "count_diff +=1";;
    2) echo 'exit 2' >&2;;
    *) echo 'some other exit' $? >&2;;
    esac

    fi
    done


  • 2.  It is not April 1st, so assuming this is not a joke

    Posted Wed October 18, 2006 08:20 AM

    Originally posted by: nagger


    There are lots of bugs in here.
    1) textfile spelt teixfile
    2) You assign textfile and then cat out1.txt
    3) my ls -al only has 9 columns so awk print $10 returns nothing
    4) You have commented out stuff - I guess you are trying to debug it
    5) What is the point of echoing 'exit 2' ?
    6) $directory2 is used but not set
    7) $line is set in a commented out line
    8) the counts are not output at the end
    and more ...

    What are you trying to do?
    I can't help thinking it must be easier to start again.

    If you are trying to compare two directories ...
    How about: diff -h -b Dir1 Dir2