Click to See Complete Forum and Search --> : sed


vose
01-23-2003, 01:53 PM
MARG!!! This shouldn't be hard, and once someone gives the answer, yes, after the fact it will be sooo easy. But for two days so far it has been totally impossible. How does one write something like

date | sed s/ ....

so that if date returns Thu Jan 23 12:14:03 EST 2003, then

date | sed s/ ....

will return 12:14:03 ?

Second question: Is there a complete and absolutely, positively, totally unambiguous DEFINITION for precisely how sed works, with examples, lots and lots of examples?

vose
01-23-2003, 02:10 PM
I should have rebooted days ago. After a powercycle, the following works just fine.

date | sed -e 's/[^ ]* [^ ]* [^ ]* //' -e 's/ .*//'

Maybe i need to upgrade to redhat 8.xx

Am still curoius about documentation though
(where examples are explained in detail)

nickptar
01-23-2003, 03:07 PM
A simpler command line is:
date | cut -f4 -d" "
See "man cut" for details. For sed help, try "info sed".

takshaka
01-24-2003, 12:06 AM
Simpler still...

date +%T