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.

Creative Commons License
This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported 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 *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

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.