Re: bash question

  • From: "Don Marang" <donald.marang@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Tue, 26 Oct 2010 12:50:48 -0400

 Now that you mention it, I think /n and /r characters do not work as 
delimiters in IFS.   I think they are not valid characters in such a string 
anyway.  I think the default IFS=" ,\t".  Meaning that Space, Comma and Tab are 
the default delimiters.  I took the risk to create a new delimiter.  I do not 
know of any standard to use in such a case.  

Bash is very powerful in manipulating filename strings.  I assume in your 
example that you are just manipulating the filename at that point and is used 
to execute a command to perform a conversion from ogg to mp3.  Using variable 
suvstitution and the special character % is very cool.  

Don Marang

There is just so much stuff in the world that, to me, is devoid of any real 
substance, value, and content that I just try to make sure that I am working on 
things that matter. 
Dean Kamen 



From: Storm Dragon 
Sent: Monday, October 25, 2010 6:36 AM
To: programmingblind@xxxxxxxxxxxxx 
Subject: Re: bash question


Hi,
I tried setting IFS="\n" but still had problems.  I got the script working 
finally though. Here's the final result. I also discovered something really 
cool for changing the extension of a file for example:
for i in ./*.ogg; do sox "$i" "${i%.ogg}.mp3";done
Thanks
Storm
      -- 
Registered Linux user number 508465:
http://counter.li.org/
My blog, Thoughts of a Dragon:
http://www.stormdragon.us/
Follow me on Twitter:
http://www.twitter.com/stormdragon2976


     
On Mon, 2010-10-25 at 05:12 -0400, Don Marang wrote: 
   I did not go through every character of your bash script, but I get the 
feeling that you are encountering problems with the default Internal Field 
Separator (IFS), which is used to separate arguments in strings like the 
command line.  It is an environment variable which by default is defined as a 
comma or space or vertical bar (|).  Not quite sure about the third character.  
In the speedy-ocr script, I set it to a character I do not expect to find in 
the filenames.  I used a colon as follows.  Since I do not export it to the 
external environment outside the script, it would get reset to the default when 
the script exits.   
   
  IFS=":" 
   
  Don Marang 
   
  There is just so much stuff in the world that, to me, is devoid of any real 
substance, value, and content that I just try to make sure that I am working on 
things that matter. 
  Dean Kamen 





  From: Storm Dragon 
  Sent: Sunday, October 24, 2010 5:03 PM 
  To: programmingblind@xxxxxxxxxxxxx 
  Subject: Re: bash question 



  Hi,
  Yes, $(commands) is the same as `commands`. So, where/how should I escape 
quotes? I thought I had everything in the right place. If you were to chage the 
word sox to echo, then sample output would be something like:
  "DragonForce - Above the Winter Moonlight.ogg" "DragonForce Above the Winter 
Moonlight.mp3"
  Thanks
  Storm
        -- 
Registered Linux user number 508465:
http://counter.li.org/
My blog, Thoughts of a Dragon:
http://www.stormdragon.us/
Get paid to read email:
http://is.gd/feRiB



       
  On Sun, 2010-10-24 at 22:47 +0200, QuentinC wrote:

     
    The form $(...) sounds strange to me because I have never seen it (I don't 
know what it does exactly, is it the same as back quotes?). But I think you 
just forgot to escape one or more quotes. 

Other related posts: