Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (4) </ 1 [2] 3 4 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Little help needed, Bash scripting< Next Oldest | Next Newest >
^thehatsrule^ Offline





Group: Members
Posts: 3275
Joined: July 2006
Posted: Jan. 30 2007,19:09 QUOTE

If you plan on using sed, you could use "s/ /\ /g"
If you plan on using a shell script, you could use IFS
(i.e.
IFS="
"
or use 'read')

Or you could just remember to never use spaces in filenames :P
Back to top
Profile PM 
Zucca Offline





Group: Members
Posts: 524
Joined: Feb. 2006
Posted: Jan. 30 2007,20:35 QUOTE

I tried that sed command and it didn't worked.
I'm thinking It should be sed -e 's/ /\\ /g'. But I'm not sure about that.

Anyway. Everybody needs to sleep sometimes. And now is my time. :p
I'm thinking this over tomorrow.


--------------
Do you have it? - http://dy.fi/mak
Back to top
Profile PM WEB ICQ MSN 
^thehatsrule^ Offline





Group: Members
Posts: 3275
Joined: July 2006
Posted: Jan. 30 2007,20:44 QUOTE

Ah you're right, I forgot the double \\ for escape and that single quotes are needed for non-sub.
Back to top
Profile PM 
Zucca Offline





Group: Members
Posts: 524
Joined: Feb. 2006
Posted: Jan. 31 2007,18:54 QUOTE

Quote (Zucca @ Jan. 30 2007,17:35)
I'm thinking It should be sed -e 's/ /\\ /g'. But I'm not sure about that.

Well It didn't. =D

I did like this:
Code Sample
echo "one two three" | sed -e 's/ /\\ /g'

It really printed: "one\ two\ three"
But if I had e file named "one two three" and I did this:
Code Sample
cat `echo "one two three" | sed -e 's/ /\\ /g'`

It would print an error message like this:
Quote
cat: one: No such file or directory
cat: two: No such file or directory
cat: three: No such file or directory

So cat still thinks that "one two three" is actually three seperate files.


--------------
Do you have it? - http://dy.fi/mak
Back to top
Profile PM WEB ICQ MSN 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Jan. 31 2007,20:04 QUOTE

while read line; do
commands
done < playlist

I still have very little idea of what you're trying to accomplish, but the above inputs lines literally.  The cat command should do the same, so I'm thinking there is a problem with the way poc or mpg321 is reading the input.  I have an mpg321 script that also didn't work with spaces in filenames, but wrapping the variable which represents the filename in quotes fixed the problem:

Code Sample
find ${DIR} | while read song; do
case "$song" in
*.mp3|*.Mp3|*.MP3) ${MP3_PLAYER} $@ "$song" && sleep 1 && clear;;
*.ogg|*.Ogg|*.OGG) ${OGG_PLAYER} $@ "$song" && sleep 1 && clear;;
esac;
done


Of course this runs a unique instance of mpg321 for each song rather than using a playlist, but the point is that I needed the filename in quotes.


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
18 replies since Jan. 30 2007,09:45 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (4) </ 1 [2] 3 4 >/
reply to topic new topic new poll
Quick Reply: Little help needed

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code