find . -mtime -n Cannot be piped to a tar command
665048Sep 14 2011 — edited Sep 16 2011Hello,
i am having a hard time trying to tar files modified since the last 1 day. I already have the command but when I pipe the same to tar, the tar subcommand includes all the files in the directory, i.e.
1. DIRECTORY FILES
bash-3.00# ls -lrth
total 22
drwxr-xr-x 2 mxp other 512 Sep 16 2010 zz.comp
drwxr-xr-x 2 mxp other 512 Aug 15 12:20 OLD
-rw-r--r-- 1 root root 3.0K Aug 15 12:20 old.des3
-rw-r--r-- 1 root root 3.5K Aug 15 12:33 sql.des3
-rwxrwxr-x 1 root root 168 Sep 14 09:58 bkp
bash-3.00#
2. FAILING SCRIPT
#!/bin/sh
LOG=/mxp/tar.log
FILE=`find /mxp/SQL -mtime 0`
tar -cvf - $FILE |encrypt -a 3des -k /etc/mykeys/backup.3des0 | dd of=/mxp/dev.tar 2>$LOG
~
3. COMMAND RUN MANUALLY
bash-3.00# find /mxp/SQL -mtime 0
/mxp/SQL
/mxp/SQL/bkp
/mxp/SQL/test
bash-3.00#
4. THE SCRIPT FAILING AS FOLLOWS
bash-3.00# ls
OLD bkp old.des3 sql.des3 test zz.comp
bash-3.00# ./bkp
a /mxp/SQL/ 0K
a /mxp/SQL/OLD/ 0K
a /mxp/SQL/OLD/test1 0K
a /mxp/SQL/OLD/test2 0K
a /mxp/SQL/OLD/test3 0K
a /mxp/SQL/zz.comp/ 0K
a /mxp/SQL/bkp 1K
a /mxp/SQL/old.des3 4K
a /mxp/SQL/sql.des3 4K
a /mxp/SQL/test 0K
./bkp: ~: not found
bash-3.00#
Do you see the problem? The whole of the DIR is tared, please help!!
Kind Regards,
Nicodemus Msuya