I'm trying to read a text file with a lot of lines and log them by using logger via bash scrip. I achieved to read the file line by line with following code
#!/bin/bash
filename=logger.txt
[[ -f ${filename} ]] || exit 1
x=0
while read -r line; do
logger "$line";
sleep 0.1;
done < $filename
exit 0
but how to read lines randomly and log them.
I'm trying it with this but without any success
#!/bin/bash
filename=logger.txt
[[ -f ${filename} ]] || exit 1
x=0
while read -r line; do
logger "%06d %s\n" $RANDOM "$line";
sleep 0.1;
done < $filename
exit 0
How could I implement the RANDOM function into the script or is there another option to achieve it? I tried shuf but it read just one line and then stopped.
Aucun commentaire:
Enregistrer un commentaire