bash shell script not working as intended using cmp with output redirection -


i trying write bash script remove duplicate files folder, keeping 1 copy. script following:

#!/bin/sh  f1 in `find ./ -name "*.txt"`     if test -f $f1             f2 in `find ./ -name "*.txt"`                     if [ -f $f2 ] && [ "$f1" != "$f2" ]                             # if cmp $f1 $f2 &> /dev/null # not work                 if cmp $f1 $f2                                     rm $f2                     echo "$f2 purged"                 fi              fi         done     fi  done  

i want redirect output , stderr /dev/null avoid printing them screen.. using commented statement script not work intended , removes files first..

i'll give more informations if needed.

thanks

&> bash syntax, you'll need change shebang line (first line) #!/bin/bash (or appropriate path bash.

or if you're using bourne shell (/bin/sh), have use old-style redirection, i.e.

cmp ... >/dev/null 2>&1 

also, think &> introduced in bash 4, if you're using bash, 3.x you'll still need old-style redirections.

ihth


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -