I'm making a (bash) script for mass keyfile generation. I need the script to name the first generated keyfile "1", the next "2" and so on - So I need every filename to be the previous filename + 1. The script so far:
#!/bin/bash
#Files in directory
dir=$(ls -U -l /home/user/keyfiles|wc -l)
name=
#script
target=/home/user/keyfiles/$name
dd if=/dev/random of=$target bs=1024 count=5
As you see, I would like to add 1 to $dir and store it in $name, every time the script is run.