带输出的碎片脚本

时间:2012-08-13 16:14:33

标签: linux bash shell scripting

我正在尝试编写一个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 &

3 个答案:

答案 0 :(得分:0)

在stdout重定向之后,&符号必须位于命令的末尾:

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

答案 1 :(得分:0)

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

尝试将其移至最后......

nohup <your shell command> &

答案 2 :(得分:0)

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

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

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

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