Mailing List ArchiveSupport open source code!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]RE: [tlug] random in bash [Kmail Notification]
- To: "'tlug@example.com'" <tlug@example.com>
- Subject: RE: [tlug] random in bash [Kmail Notification]
- From: Paul Richter <PaulR@example.com>
- Date: Fri, 8 Mar 2002 09:58:30 +0900
- Content-type: text/plain;charset="ISO-2022-JP"
- Reply-to: "Richter Paul (E-mail)" <RichterPN@example.com>
OK, I wrote a bash script that will print one randomly chosen line from a specified file. Eric wanted Kmail to play a randomly picked soundfile every time a mail arrived. So, if there's a text file listing all the sound files to choose from (filelist.txt), you could call this script 'randline' and do >$ artsplay `randline filelist.txt` ---------------------------------------- #!/bin/bash #prints one randomly chosen line from a specified file INFILE=$1 #all that piping is because wc -l prints formatted output instead # just a single number LINECOUNT=`wc -l $INFILE | tr -s ' ' | cut -d ' ' -f 2` # RANDOM returns 0 - 32767, so normalize it to 1 - LINECOUNT let LINENUM=(1+($RANDOM%$LINECOUNT)) head -n $LINENUM $INFILE | tail -n 1 # end of script ---------------------------------------- Paul Richter RichterPN@example.com
- Follow-Ups:
- Re: [tlug] random in bash [Kmail Notification]
- From: Eric O. Flores
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] random in bash [Kmail Notification]
- Next by Date: Re: [tlug] random in bash [Kmail Notification]
- Previous by thread: RE: [tlug] random in bash [Kmail Notification]
- Next by thread: Re: [tlug] random in bash [Kmail Notification]
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links