GearHack

: :

Add Comment | Related Links | TrackBack
Related Content

egrep ignores begin of line on Mac OS X

Darwin UNIX commands doesn't always seem to follow standard rules, such as the "sed won't produce new line on Mac OS X " issue. I just found another exception:

$ echo "Contagion" | egrep -o '^.'
C
o
n
t
a
g
i
o
n

It's not suppose to do that. It completely ignored the beginning line character in the regular expression. The same example produced the correct result on Ubuntu Linux:

$ echo "Contagion" | egrep -o '^.'
C

Luckily, there is an easy work around that will work on both systems:

$ echo "Contagion" | egrep -o '^.' | head -1
C

Just wished I didn't have to resort to thtat.

Chieh Cheng
Fri, 20 Jan 2012 03:38:32 +0300

Add Comment | Related Links | TrackBack
Related Content

Did your message disappear? Read the Forums FAQ.

Add Comment

Spam Control | * indicates required field
Your Name: *
E-mail:
Remember Me!
Comment: *
File attachment is optional. Please do not attach a file to your submission unless it is relevent.
Attach File:
(20 MB Max)
Spam Protection: * Answer of 5 - 4?
Click button only once, please!

TrackBack

Send Ping | TrackBack URL | Spam Control

No TrackBacks yet. TrackBack can be used to link this thread to your weblog, or link your weblog to this thread. In addition, TrackBack can be used as a form of remote commenting. Rather than posting the comment directly on this thread, you can posts it on your own weblog. Then have your weblog sends a TrackBack ping to the TrackBack URL, so that your post would show up here.

Messages, files, and images copyright by respective owners.


Articles | Wiki
Forums | Latest | RSS
Library | Links | News
Search | Store | Help

37 Users Online


Hacking Digital Cameras
Fun for Photographers

Amazon Associate

Copyright © 2004 - 2017. All Rights Reserved.