Go Back   The UNIX and Linux Forums > Top Forums > Emergency UNIX and Linux Support !! Help Me!!
Search Forums:



Emergency UNIX and Linux Support !! Help Me!! Post your urgent questions here for highest visibility. Posting a new thread to this forum requires Bits. We monitor this forum to help people with emergencies, but we do not guarantee response time or answers. This forum is "best effort" only. Members who reply to posts here receive a bonus of 1000 Bits per reply.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-07-2010
Registered User
 

Join Date: Sep 2008
Posts: 71
Thanks: 6
Thanked 1 Time in 1 Post
sed on Mac OS versus Linux

I'm trying to replace space with inderscore on Mac OS X 10.6.3
sed -i 's/ /_/g' somefile
sed: 1: "hsa_mirbase.fa": extra characters at the end of h commandThis works perfectly fine on Linux.
Thank you
Joseph Dhahbi
Sponsored Links
    #2  
Old 06-07-2010
Scott's Avatar
Scott Scott is online now Forum Staff  
Administrator
 

Join Date: Jun 2009
Location: Switzerland - ZH
Posts: 5,321
Thanks: 128
Thanked 526 Times in 465 Posts
Hi.

From the OSX man page for SED:


Code:
-i extension
  Edit files in-place, saving backups with the specified extension.

So, for example:

Code:
sed -i.bak 's/ /_/g' somefile

(I guess that the extension is optional on Linux, but may be provided (will check!))

(actually, without checking too much, according to the man page here, it is optional)

(actually #2, the OSX man page is rubbish! It suggests that it is optional, but complains when it's not given)


Code:
-i extension
             Edit files in-place, saving backups with the specified extension.  If a zero-length extension is given,
             no backup will be saved.  It is not recommended to give a zero-length extension when in-place editing
             files, as you risk corruption or partial content in situations where disk space is exhausted, etc.


Last edited by Scott; 06-07-2010 at 03:57 PM..
The Following User Says Thank You to Scott For This Useful Post:
jdhahbi (06-07-2010)
Sponsored Links
    #3  
Old 06-07-2010
Registered User
 

Join Date: Sep 2008
Posts: 71
Thanks: 6
Thanked 1 Time in 1 Post
Thank you for your help
    #4  
Old 07-27-2010
Registered User
 

Join Date: Jul 2010
Location: Aberystwyth, Wales, UK
Posts: 10
Thanks: 3
Thanked 0 Times in 0 Posts
SED on OS X is the BSD version (certainly is on OS X 10.6.4).

I have found that GNU versions of UNIX utilities often have far more options available to them, the danger is that if you know the extra options, you'll miss them on BSD based systems.

Ben
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Awk Versus Cut jaysunn Shell Programming and Scripting 6 12-29-2009 09:36 AM
AIX versus Networks rawatmohinder AIX 5 05-23-2006 05:54 AM
<LF> versus <CR>/<LF> jerardfjay Shell Programming and Scripting 1 10-20-2005 06:09 PM
CTRL+H versus ^? versus BACKSPACE alan UNIX for Dummies Questions & Answers 3 07-23-2003 01:08 PM



All times are GMT -4. The time now is 11:09 PM.