Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying write a script to find all changes (modify,create,delete) in a list of directories for last 24h, as the following :


OUTPUT=$LOGDIR/$(date +%Y-%m-%d).log

function start_check {
    for i in `find . -name $DIR -type d`;do
        for j in `find $i -name "${FILETYPE}"`;do           
            case `find $j -mtime -1` in
                    if [ "$used" = "0" ];then
                        current_directory=`echo $i | cut -d'/' -f2`
                        display "$current_directory"
                        echo $j >> $OUTPUT

function display {
    echo "---------------------------------------" >> $OUTPUT;
    echo "$@" >> $OUTPUT;
    echo "---------------------------------------" >> $OUTPUT;




Problem is , when I run the script in Ubuntu, I can't find any problem , but when I run the script in centos, it can't find any changes, the result is NULL .
Any idea?

share|improve this question

well, its a bash script, so i'd recommend you to debug the program by executing line by line by copying line by line into a terminal and see where it is that it fails,

for example, one potential cause of the problem is that in centos, for some reason it's not finding any files/folders, so manually execute the find . -name "www" -type d instruction and see if it returns an expected result.

Repeat that process for every instruction in your program, it shouldn't take long since its a small program.

share|improve this answer
i already have execute line by line manually , i have no problem with that as well , problem start when i run the script all togother ,,, – moata_u Dec 1 '12 at 7:48
lets see what shell are you using, what's the output of "ps -p $$" and whats the output of "which bash" – Sam Dec 1 '12 at 18:00
both centos and ubuntu have same result : bash , /bin/bash – moata_u Dec 2 '12 at 6:26
how is that you'r executing the script? you should also try to "echo" variables in different parts of your script so see where's that it's failling – Sam Dec 3 '12 at 3:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.