0

我正在尝试编写一个 shred 脚本以将删除的文件输出到文本文件,但我认为我的输出有问题?我还考虑在脚本中添加一个电子邮件部分,以便在删除所有文件后发送电子邮件确认,但首先需要让输出工作到文本文件中。

谢谢

#!/bin/bash

# Use on remote server

LOCATION="/home/user/Test"
TIMES=-n38

cd $LOCATION

# Delete all files in location 30 times

echo "Deleting all delete located at $LOCATION "

nohup find $LOCATION -exec shred $TIMES -u '{}' \; & >> /home/user/output.txt

echo "All data at $LOCATION has been shredded $TIMES times"

# Delete the partition

#nohup shred -n 30 -vz /dev/sdb1 &
4

3 回答 3

0

&符号需要在命令的末尾,在标准输出重定向之后:

nohup find $LOCATION -exec shred $TIMES -u '{}' \; >> /home/user/output.txt &
于 2012-08-13T16:23:38.497 回答
0

&将进程置于后台;所以在shell命令之间使用它不是要走的路......

试着把它移到最后......

nohup <your shell command> &
于 2012-08-13T16:30:54.637 回答
0

1)添加-print选项到find命令,例如

find $LOCATION -print -exec shred $TIMES -u '{}' \;

2)正如其他人已经指出的那样,将&符号移到最后

3)不shred $TIMES应该shred -n $TIMES吗?

于 2012-08-13T16:34:57.537 回答