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:

  1. is possible achieve goal joining 2 commands? (pipe them? how?)

  2. 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

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -