-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use mktemp. If not available, create a random dir manually, using awk's rand() and $$. Not a pretty solution, but it's portable. Fixes #12
- Loading branch information
1 parent
ee0c6f2
commit fba9c0e
Showing
2 changed files
with
21 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
awk 'BEGIN { srand(); print rand() }'
This section will generate a number between 0 and 1, for example 0.466486, with the decimal point.
You can use this notation to avoid this, if desired:
awk 'BEGIN { srand(); printf "%.0f\n", rand()*1e6 }'
Or if you want to consider using hexadecimal characters:
awk 'BEGIN { srand(); printf "%X\n", sprintf("%.0f\n", rand()*1e6) }'
P.S.: instead of 1E6 can be 1000000 or precision you want.