vendredi 4 février 2022

Why am I getting the same number when I call $RANDOM in this context?

I wrote a simple bash alias to create a sort of daily tmp directory to work in:

alias datdir="mkdir $(date +'%m_%d_%Y')___$RANDOM"

When I call it repeatedly on the same day, I get this:

mkdir: cannot create directory ‘02_04_2022___24499’: File exists

However, when I simply run echo $RANDOM on the terminal, I get different numbers.

I'm running Git Bash on Microsoft Windows 10 Business, Version 10.0.19044 Build 19044

$ bash --version
GNU bash, version 4.4.23(1)-release (x86_64-pc-msys)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.



Aucun commentaire:

Enregistrer un commentaire