C
C
ChymeNik2018-04-29 01:12:39
linux
ChymeNik, 2018-04-29 01:12:39

How to link to a random file from a folder in Linux?

I have an images folder, it contains files 0.jpg, 1.jpg, ...
How can I make it so that, for example, the link /home/user/image.jpg shows a random image from the folder?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pfg21, 2018-04-29
@pfg21

the link to the file is "hard", i.e. points exactly to a specific file. those. getting a random file through fs just won't work.
you can get the name of a file by calling a bash script with '' , which will generate a name with the required name or give the contents of some file.
generating a random number from a range is done in shuf

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question