Re: Return character after sed
Re: Return character after sed
- Subject: Re: Return character after sed
- From: Axel Luttgens <email@hidden>
- Date: Sun, 25 Feb 2007 14:31:15 +0100
On 24/02/07 14:04, email@hidden wrote:
Hi
I have i line to get the time part from the boottime command. It works
fine but I get a return or new line character at the end.
More exactly, one gets two consecutive newlines; as an attempt to
materialize those invisible characters in sysctl(8)'s output:
$ sysctl kern.boottime
kern.boottime = Mon Feb 19 11:09:13 2007<newline>
<newline>
Why do I get this end character,
Well, il looks like that, when fetching the boot time, sysctl(8) itself
receives such a newline character, and just reports it as belonging to
the data.
Have a look at the output of:
sysctl -a
You'll notice empty lines after kern.boottime and kern.bootsignature;
all other values are reported on their own single line.
There may be a good reason for such a behavior, but I presently don't
see which one... ;-)
and how can I get rid of it?
See below.
Here is my line:
do shell script "/usr/sbin/sysctl kern.boottime | cut -c 28-35 | sed
s/:/./g"
As it seems you anyway want to have sed(1) perform some substitution,
you have the opportunity to ask it to skip the empty line in its output,
as well as to perform the job of cut(1) at the same time:
/usr/sbin/sysctl kern.boottime | sed -nE 's/^kern.
boottime = ([^:]+):([^:]+):(.+)$/\1.\2.\3/p'
(the above should of course be a one-liner, but I have split it after
the "." of "kern.bootime" in the hope to avoid an arbitrary cut during
mail transport)
HTH,
Axel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden