Posted: . At: 10:31 AM. This was 4 years ago. Post ID: 14112
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


Very interesting and strange bash trick with ls.


This is a very interesting bash trick I found using ls. This runs the ls command with random parameters. This is not very useful, but interesting nonetheless.

4.4 Tue Mar 03 jason@Yog-Sothoth 0: $ ls -`cat /dev/urandom | tr -dc 'hula' | head --bytes 1`

This is another example, this does work very well.

4.4 Tue Mar 03 jason@Yog-Sothoth 0: $ ls -`cat /dev/urandom | tr -dc 'hula' | head --bytes 3`
total 24
drwxr-xrwx+  2 jason jason  4096 Mar  3 10:07 .
drwxr-xr-x+ 52 jason jason 12288 Mar  3 10:06 ..
-rw-r--rw-   1 jason jason  6590 Aug 28  2019 user.ltx

I do not know why you would use this, but this is an interesting trick nonetheless. I just wish I could use tr without cat. But what can you do?

Using the tr command like this, all of the letters are jumbled up into a random string.

tr -dc 'hula'

This could be used to generate a very complicated password though…

4.4 Tue Mar 03 jason@Yog-Sothoth 0: $ cat /dev/urandom | tr -dc '[a-zA-Z0-9]' | head --bytes 36
qXKM8ZHm2wD5smNtRCtj7M0pilxGrBti5yFX

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.