Re: getting date from timestamp
- From: Barry Margolin <barmar@xxxxxxxxxxxx>
- Date: Thu, 28 Sep 2006 12:32:17 -0400
In article <1159458333.353715.103030@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
"pawan_test" <sridhara007@xxxxxxxxx> wrote:
Hi All,
i have a time stamp. from that i am trying to awk to get the year,
month and date.
TIME=20060614092446
DESIRED OUTPUT: 20060614
i am doing the following;
TIME=20060614092446
$ TimeStarted=`expr match '$TIME' '.*\(......\)'`
echo $TimeStarted
i am not getting any output. can anyone please suggest me.
Single quotes prevent variable expansion, use double quotes.
Also, your regular expression is incorrect, it should be '^\(........\)'
to get the first 8 characters -- your expression will grab the last 6
characters.
You can also do this without regular expressions at all, just shell
variable substring syntax:
TimeStarted=${TIME:0:8}
--
Barry Margolin, barmar@xxxxxxxxxxxx
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
.
- References:
- getting date from timestamp
- From: pawan_test
- getting date from timestamp
- Prev by Date: Re: Thread cancellation
- Next by Date: Remove the first 3 characters after reading each line
- Previous by thread: getting date from timestamp
- Next by thread: Remove the first 3 characters after reading each line
- Index(es):
Relevant Pages
|