Linux fill all files recursivelly with random or pseudo random data -
i want fill random bytes files recursivelly root directory. files, folders left untoutched
i don´t want delete files, fill them random bytes
in research, fill command single file like:
dd if=/dev/random of=target-files bs=1m
and find files recursivelly should use:
find . -name "* .*"
my questions are:
is possible achieve goal joining 2 commands? (pipe them? how?)
is there easier way achieve same results?
thanks ;-)
you may try pipe find result while loop, , dd /dev/udrandom each files.
$ find myfolder -type f |while read fd; dd if=/dev/urandom of=$fd bs=1m count=1;done
if want retain file size, may calculation on finding 1k block count , pass args in dd.
$ find myfolder -type f|while read fd; fsiz=`stat -c %s $fd`; cnt=`expr $fsiz / 1024`;dd if=/dev/urandom of=$fd bs=1k count=$cnt;done
Comments
Post a Comment