Сгененировать файлы со случайной датой

Дата публикации: 09 06 2015 Автор: PazitiFF
#!/bin/bash
 
PATH_TO_DIR="path/to/dir"
for i in {1..10}
do
 
DATE=`date -d "$((RANDOM%10+2005))-$((RANDOM%12+1))-$((RANDOM%28+1)) $((RANDOM%23+1)):$((RANDOM%59+1)):$((RANDOM%59+1))" '+%Y%m%d%H%M'`
 
dd if=/dev/urandom of=$PATH_TO_DIR/sample-$i.txt bs=1M count=1
touch -t $DATE $PATH_TO_DIR/sample-$i.txt
   echo "File sample-$i.txt created"
done

Add new comment

Plain text

  • No HTML tags allowed.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <apache>, <bash>, <css>, <drupal6>, <html5>, <javascript>, <mysql>, <php>.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.