Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED.173-230-161-134.cable.teksavvy.com!not-for-mail From: "Chris F.A. Johnson" Newsgroups: comp.os.linux.misc Subject: Re: Extract "Last checked" from extX filesystem Date: Mon, 22 Apr 2013 18:11:07 -0400 Organization: A noiseless patient Spider Lines: 35 Message-ID: References: Reply-To: cfajohnson@gmail.com Injection-Info: mx05.eternal-september.org; posting-host="173-230-161-134.cable.teksavvy.com:173.230.161.134"; logging-data="26620"; mail-complaints-to="abuse@eternal-september.org" User-Agent: slrn/0.9.8.1 (Linux) Xref: csiph.com comp.os.linux.misc:7959 On 2013-04-22, Bit Twister wrote: > On 22 Apr 2013 13:53:26 -0700, Vilmos Soti wrote: >> Hello, >> >> I would like to extract the "Last checked" field from >> extX filesystems. >> >> The trick is that I need it in a form something like >> "seconds since epoch" so I can easily test it >> programmatically for any length of time. >> >> Unfortunately, dumpe2fs returns the field in a human >> readable form, and I would like to avoid to convert >> it to seconds. >> >> Is there a way to accomplish it? > > You could try something like > set $(dumpe2fs -h /dev/sdb5 | grep 'Last checked') > shift 3 > _date="$@" > _epoch=$(date --date="$date" +%s) > > echo "$_date is $_epoch" Or: read -a x < <(sudo dumpe2fs -h /dev/sdb6 2>/dev/null | grep 'Last checked:') echo "${x[@]:3}" -- Chris F.A. Johnson, Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)