|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Given this file called playlist.txt:
"/music/Country/Rascal Flatts/Rascal Flatts/It's Not Just Me.mp3" "/music/Rock/AC-DC/Back In Black/AC-DC - 09 - Shake A Leg.mp3" If I cat the file in a meta command, it breaks up each line on the spaces (See below) How can I ensure the entire line is passed to an application like mplayer? for i in $(cat playlist.txt); do echo "$i"; done "/music/Country/Rascal Flatts/Rascal Flatts/It's Not Just Me.mp3" "/music/Rock/AC-DC/Back In Black/AC-DC - 09 - Shake A Leg.mp3" |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On 3/20/2008 10:18 PM, somebody wrote: > Given this file called playlist.txt: > > "/music/Country/Rascal Flatts/Rascal Flatts/It's Not Just Me.mp3" > "/music/Rock/AC-DC/Back In Black/AC-DC - 09 - Shake A Leg.mp3" > > If I cat the file in a meta command, it breaks up each line on the spaces > (See below) How can I ensure the entire line is passed to an application > like mplayer? > > > for i in $(cat playlist.txt); do echo "$i"; done > "/music/Country/Rascal > Flatts/Rascal > Flatts/It's > Not > Just > Me.mp3" > "/music/Rock/AC-DC/Back > In > Black/AC-DC > - > 09 > - > Shake > A > Leg.mp3" Try this: while IFS= read -r i do printf "%s\n" "$i" done < playlist.txt Ed. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
2008-03-20, 23:18(-04), somebody:
> Given this file called playlist.txt: > > "/music/Country/Rascal Flatts/Rascal Flatts/It's Not Just Me.mp3" > "/music/Rock/AC-DC/Back In Black/AC-DC - 09 - Shake A Leg.mp3" > > If I cat the file in a meta command, it breaks up each line on the spaces > (See below) How can I ensure the entire line is passed to an application > like mplayer? [...] That file happens to be in a format recognised by xargs, so that's only: xargs echo < playlist.txt See man xargs for more options. -- Stéphane |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On 2008-03-21, Stephane CHAZELAS <this.address@is.invalid> wrote:
> > > 2008-03-20, 23:18(-04), somebody: >> Given this file called playlist.txt: >> >> "/music/Country/Rascal Flatts/Rascal Flatts/It's Not Just Me.mp3" >> "/music/Rock/AC-DC/Back In Black/AC-DC - 09 - Shake A Leg.mp3" >> >> If I cat the file in a meta command, it breaks up each line on the spaces >> (See below) How can I ensure the entire line is passed to an application >> like mplayer? > [...] > > That file happens to be in a format recognised by xargs, so > that's only: > > xargs echo < playlist.txt > See man mplayer. You can use a playlist file on the command line. (Not sure if it requires a special file format, but that's easy to find out.) |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Thu, 20 Mar 2008 23:18:26 -0400, somebody wrote:
> Given this file called playlist.txt: > > "/music/Country/Rascal Flatts/Rascal Flatts/It's Not Just Me.mp3" > "/music/Rock/AC-DC/Back In Black/AC-DC - 09 - Shake A Leg.mp3" > > If I cat the file in a meta command, it breaks up each line on the > spaces (See below) How can I ensure the entire line is passed to an > application like mplayer? > > > for i in $(cat playlist.txt); do echo "$i"; done "/music/Country/Rascal > Flatts/Rascal > Flatts/It's > Not > Just > Me.mp3" > "/music/Rock/AC-DC/Back > In > Black/AC-DC > - > 09 > - > Shake > A > Leg.mp3" You don't specify which shell you're using, but in bash, it's possible to specify a "read" command without any variable, in which case the entire line is read and stored in the default $REPLY variable. For example: while read do mplayer "$REPLY" done < playlist.txt Caveat: anytime you find yourself using "cat", try thinking again about an alternative way to accomplish what you're trying to do. UUOC (Useless Use Of Cat) awards abound in Usenet. -- Conrad J. Sabatier <conrads@cox.net> "Procrastinate now; don't put it off." -- Ellen Degeneres |
|
![]() |
| Outils de la discussion | |
|
|