Shell script music

Well, it seems I have the dubious distinction of being one of
the few (if any) people to discover a way to play music using shell
script. Observe the following snippet:

/usr/bin/yes foo > /dev/dsp & SP="${!}"; sleep 1; kill
"$SP"
The more characters in the argument to /usr/bin/yes,
the lower the tone. The length of the sleep argument determines how
long the tone lasts, but a pre-constructed string of repeating
“foo\n” components will do just as well, though you need about a
thousand of them to last one second.

CC BY-SA 4.0 Shell script music by Stephan Sokolow is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

This entry was posted in Geek Stuff. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution under the same terms as the associated post.

All comments are moderated. If your comment is generic enough to apply to any post, it will be assumed to be spam. Borderline comments will have their URL field erased before being approved.