|
Home > Archive > Unix questions > September 2006 > usiung sed to retrieve the hour in a timestamp
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
usiung sed to retrieve the hour in a timestamp
|
|
| landre@gmail.com 2006-09-28, 1:20 pm |
| Greetings.
I have a ksh script that greps the contents of a log file, into an
array, selecting only what I want.
the output to a CSV looks like this:
Jun 1 2005|21:08:34|/dir1/dir2/dir3/dir4/filename.txt
the time stamp (21:08:34) is a value in my array and I want to extract
only the hours from it to use elsewhere. in this case, "21"
my knowledge of "sed" is pretty limited, so I'm not sure how I could
parse
${ARRAY[ARRAYINDEX+3]} to return only "21".
Please let me know if you have any suggestions. I'd also like to use
the same approach to return only the filename. basename doesn't like
the size of the array.
Thanks a lot!!!
| |
| Bill Marcum 2006-09-28, 7:27 pm |
| On 28 Sep 2006 11:17:08 -0700, landre@gmail.com
<landre@gmail.com> wrote:
> Greetings.
>
> I have a ksh script that greps the contents of a log file, into an
> array, selecting only what I want.
>
> the output to a CSV looks like this:
>
> Jun 1 2005|21:08:34|/dir1/dir2/dir3/dir4/filename.txt
>
> the time stamp (21:08:34) is a value in my array and I want to extract
> only the hours from it to use elsewhere. in this case, "21"
>
> my knowledge of "sed" is pretty limited, so I'm not sure how I could
> parse
>
> ${ARRAY[ARRAYINDEX+3]} to return only "21".
>
echo ${ARRAY[ARRAYINDEX+3]}| sed 's/.*|\(..\):.*/\1/'
--
Perl 5 introduced everything else, including the ability to introduce
everything else.
-- Larry Wall in <199702252152.NAA28845@wall.org>
|
|
|
|
|