mardi 25 juin 2019

Random String in Bash Script [duplicate]

This question already has an answer here:

I am trying to play a random .wav file from the command line. The files are called 1.wav, 2.wav, .... 10.wav

I have created the following .sh script and given it the appropriate execution rights:

#!/bin/sh
rnd=$((1 + RANDOM % 10))
cmd="aplay -D default:CARD=Device ./$rnd.wav"
echo $cmd

and it always returns

aplay -D default:CARD=Device ./1.wav

What am I missing? Thanks for your help!




Aucun commentaire:

Enregistrer un commentaire