Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It depends on (a) how attached you are to the number 7 as opposed to, say, Lemons, and (b) whether any of your file names contain newlines (and whether you're willing to rename them if they do).</p> <p>There are many ways to deal with it, but some of them are:</p> <pre><code>mplayer Lemon*.mp3 find . -name 'Lemon*.mp3' -exec mplayer {} ';' i=0 for mp3 in *.mp3 do i=$((i+1)) [ $i = 7 ] &amp;&amp; mplayer "$mp3" done for mp3 in *.mp3 do case "$mp3" in (Lemon*) mplayer "$mp3";; esac done i=0 find . -name *.mp3 | while read mp3 do i=$((i+1)) [ $i = 7 ] &amp;&amp; mplayer "$mp3" done </code></pre> <p>The <code>read</code> loop doesn't work if file names contain newlines; the others work correctly even with newlines in the names (let alone spaces). For my money, if you have file names containing a newline, you should rename the file without the newline. Using the double quotes around the file name is key to the loops working correctly.</p> <p>If you have GNU <code>find</code> and GNU <code>xargs</code> (or FreeBSD (*BSD?), or Mac OS X), you can also use the <code>-print0</code> and <code>-0</code> options, as in:</p> <pre><code>find . -name 'Lemon*.mp3' -print0 | xargs -0 mplayer </code></pre> <p>This works regardless of the contents of the name (the only two characters that cannot appear in a file name are slash and NUL, and the slash causes no problems in a file path, so using NUL as the name delimiter covers everything). However, if you need to filter out the first 6 entries, you need a program that handles 'lines' ended by NUL instead of newline...and I'm not sure there are any.</p> <p>The first is by far the simplest for the specific case on hand; however, it may not generalize to cover your other scenarios that you've not yet listed.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload