vendredi 2 octobre 2015

How to Set Echo Variable to Sed Text Change Dynamically

i have an echo file that output a random line from a random.txt

echo $var4 | sed -n $((1+$RANDOM%`wc -l random.txt | cut -f 1 -d ' '`))p random.txt

Everytime the echo $var4 gives a random line of the file random.txt

Now i have another file playlist.txt

Inside the file playlist i've setted

a=$random
b=$random
c=$random
d=$random

and so on...

What i want is to replace the $random on a,b,c,d with different output of the echo dynamically

I've tried with

sed -i s/'$random'/$echo $var4 | sed -n $((1+$RANDOM%`wc -l random.txt | cut -f 1 -d ' '`))p random.txt/ playlist.txt

But it doesn't work,

any suggestion?




Aucun commentaire:

Enregistrer un commentaire