Re: Date from the time stamp
- From: "Chris F.A. Johnson" <cfajohnson@xxxxxxxxx>
- Date: Thu, 28 Sep 2006 13:24:36 -0400
On 2006-09-28, pawan_test 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
You do not need any external program.
In any POSIX shell:
TimeStarted="${TIME%${TIME#????????}}"
With bash or ksh93:
TimeStarted=${TIME:0:8}
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
.
- References:
- Date from the time stamp
- From: pawan_test
- Date from the time stamp
- Prev by Date: Re: [newbie] How to copy and paste many command at once ?
- Next by Date: Re: Remove the first 3 characters after reading each line
- Previous by thread: Re: Date from the time stamp
- Next by thread: Remove the first 3 characters after reading each line
- Index(es):
Relevant Pages
|