Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Trouble with SED

Trouble with SED
Thread Tools
Mac Enthusiast
Join Date: Apr 2001
Status: Offline
Reply With Quote
Mar 25, 2005, 08:20 AM
 
i'm doing something pretty basic which works fine on OSX
but fails on MS_DOS bat file usage.

echo filename.nfo | sed "s/\.nfo//g" >temp.txt

In OSX the temp.txt has in it exactly what it should "filename"


in MS-DOS I get "filename " <---- NOTE the SPACE character at the end


What the heck is wrong with sed on MS-DOS? and does anyone
know how i can get it to NOT add that space at the end? is there
an option I can add to DOS sed to get it to NOT do that?

here is more of the script in the bat file

set AE_NFO=filename.nfo
echo %AE_NFO% | sed "s/\.nfo//g" >temp.txt
set /p AE_FILENAME=< temp.txt



Thoughts?


thanks!
     
Groovy  (op)
Mac Enthusiast
Join Date: Apr 2001
Status: Offline
Reply With Quote
Mar 26, 2005, 08:21 AM
 
Originally posted by Groovy:


set AE_NFO=filename.nfo
echo %AE_NFO% | sed "s/\.nfo//g" >temp.txt
set /p AE_FILENAME=< temp.txt

haha hate replying to my own posts but i figured out how to fix it and WHY
DOS sed is different. The version with XP just does it wrong. You can download
better versions of sed though which i didn't want to do and because I figured
out how to get sed to work like i needed.

simply add a [space character]$ like the following causes sed to strip (or suppress)
that character from being sent to output at the EOF.

echo %AE_NFO% | sed "s/\.nfo $//g" >temp.txt



my script works great now on both OSX and MS-DOS/XP boxes
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 04:59 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2