Home
Man
Search
Today's Posts
Register

Please 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.

sed on Mac OS versus Linux

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 06-07-2010
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
# 2  
Old 06-07-2010
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 04:57 PM..
The Following User Says Thank You to Scott For This Useful Post:
jdhahbi (06-07-2010)
# 3  
Old 06-07-2010
Thank you for your help
# 4  
Old 07-27-2010
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
Login to Reply

« Previous Thread | Next 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
GNU sed running on Mac Xterra Shell Programming and Scripting 5 10-11-2018 06:13 PM
Redhat versus Ubuntu Linux distribution cmccabe Red Hat 5 09-24-2015 10:43 AM
Vm versus physical linux server bigbenn Shell Programming and Scripting 15 07-09-2013 04:38 PM
Mac OS X sed, add newline after pattern pburge UNIX for Dummies Questions & Answers 9 06-11-2013 12:46 PM
Duplicating MAC linux or net? karlochacon UNIX for Dummies Questions & Answers 1 10-18-2010 04:58 PM
detect mac address modication in linux shivarajM UNIX for Advanced & Expert Users 1 05-10-2009 06:44 PM
fcntl works in linux but not in mac os x newhere Programming 3 03-08-2009 07:22 AM
logout script common for both Mac and Linux? harsha10 UNIX for Advanced & Expert Users 0 06-27-2008 03:17 PM
Transfer Files from old Mac to a Linux box? wsimpso1 UNIX for Dummies Questions & Answers 3 05-10-2006 12:13 PM
CTRL+H versus ^? versus BACKSPACE alan UNIX for Dummies Questions & Answers 3 07-23-2003 02:08 PM
running linux ppc on a mac 7200 ignus UNIX for Advanced & Expert Users 2 10-02-2001 12:10 AM


All times are GMT -4. The time now is 08:42 PM.

Unix & Linux Forums Content Copyright 1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password