Fedora Linux Support Community & Resources Center
  #1  
Old 12th December 2009, 10:36 PM
joe.pelayo's Avatar
joe.pelayo Offline
An ape descendant
 
Join Date: Dec 2006
Location: Mexico City
Age: 29
Posts: 3,101
macosfirefox
Replace command 'sed' when porting to Mac OSX

Hello everybody.

To start with I am not sure if this is posted in the right section (might as well fit in programming). Being said that I'll present my problem.

As a part of a bigger program (which is basically a bunch of Fortran routines and bash scripts) I added the instruction (found the suggestion in a forum):
Code:
sed -i '1d' textfile
which removes the first line of the textfile and saves changes in the same file. I did this in my Fedora powered laptop and worked like a charm. The problem is that I need to temporarily move the development of the program to a Mac, and after installing all necessary software (gnuplot and such) the program fails at the point where the sed instruction is called. After checking its help page (in OSX) I found a paragraph that 'confirmed my fears':
Code:
STANDARDS
     The sed utility is expected to be a superset of the IEEE Std 1003.2
     (``POSIX.2'') specification.

     The -E, -a and -i options are non-standard FreeBSD extensions and may not
     be available on other operating systems.
from what I understand the sed instruction is not standard between Linux and BSD (OSX), right?

Being that the case I consider the safest thing to do is to find an alternative way of removing the first line of my file (something that works in both *nixes).

Is there an alternate method of removing the first line of a file with bash?

Thanks,
Joe.
__________________
Notebook: Acer Aspire 5536-5112.
AMD Athlon X2 QL64 @ 2.1GHz, 4GB DDR2 PC2-5300, ATI Radeon HD3200 (256MB), 250GB Toshiba HDD, HL-DT-ST DVDRAM GT20N
Fedora 16 x86_64

Netbook: Acer Aspire One A150
Intel Atom N270 @ 1.6GHz, 1.5 GB DDR2 PC2-4200, Intel Graphics (8MB?), 160GB Seagate HDD
Fedora 15 i686
Reply With Quote
  #2  
Old 13th December 2009, 01:04 AM
Dies Offline
Registered User
 
Join Date: Oct 2006
Posts: 4,752
linuxfedorafirefox
Somebody probably has a proper answer, but I like to take the lazy way out so I would just do
Code:
cat textfile | sed '1d' > textfile
Though you might want to make a temporary copy to use as input then delete it.
Reply With Quote
  #3  
Old 13th December 2009, 05:27 AM
joe.pelayo's Avatar
joe.pelayo Offline
An ape descendant
 
Join Date: Dec 2006
Location: Mexico City
Age: 29
Posts: 3,101
linuxsafari
Quote:
Originally Posted by Dies View Post
Somebody probably has a proper answer, but I like to take the lazy way out so I would just do
Code:
cat textfile | sed '1d' > textfile
Though you might want to make a temporary copy to use as input then delete it.
Thanks for your reply Dies.

I just figured out a solution for the problem by dropping the -i parameter and directing the input of the command like
Code:
sed 1d textfile > anothertextfile
After that I just renamed the file back to its former name. Works in both platforms

Thanks,
Joe.
__________________
Notebook: Acer Aspire 5536-5112.
AMD Athlon X2 QL64 @ 2.1GHz, 4GB DDR2 PC2-5300, ATI Radeon HD3200 (256MB), 250GB Toshiba HDD, HL-DT-ST DVDRAM GT20N
Fedora 16 x86_64

Netbook: Acer Aspire One A150
Intel Atom N270 @ 1.6GHz, 1.5 GB DDR2 PC2-4200, Intel Graphics (8MB?), 160GB Seagate HDD
Fedora 15 i686
Reply With Quote
Reply

Tags
command, mac, osx, porting, replace

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting 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 Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Feodra 9 will not boot farther than the command prompt after compiz --replace Caleb Burns Using Fedora 3 19th August 2008 09:10 PM
Porting?? Lascolb Using Fedora 8 9th February 2008 12:17 AM
Porting my app to Mono... what should I do? cypher543 Programming & Packaging 1 25th May 2006 04:01 AM
Porting Linux to Zen Booyaka Linux Chat 0 5th February 2005 06:14 AM


Current GMT-time: 02:08 (Thursday, 20-06-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat