selecteer random files from a directory for moving

on

ls | sort -R | head -n 10 | sed ‘s/^\(.*\)$/mv \”\1\” zzz_move/g’ > zzz_move.sh

This script will create a file zzz_move.sh with 10 files/directories from current directory with a mv command.

What happens here:

ls: list all files and directories in current dir

sort -R: sort list randomly

head -n 10: take only the first 10 of this random list

sed command:

^\(.*\)$ take the complete string

/mv \”\1\” zzz_move

build a new string:

mv then the complete selected string (\1) and then zzz_move