using awk on a variable
Ray Parrish
crp at cmc.net
Thu Jan 21 16:00:20 UTC 2010
Nils Kassube wrote:
> Ray Parrish wrote:
>
>> I have the following code which is not working -
>>
>> ReturnValue="`ls -als "$Package"`"
>> if [[ "$ReturnValue" != "" ]]
>> then
>> DateTime="`awk "$ReturnValue" { print $7, $8 }`"
>> echo "$DateTime"
>> return
>> fi
>>
>
> Sorry, I don't speak awk, so I can't help you with the awk problem. But
> isn't that a bit complicated to get the date of a file using the ls
> command and then extracting the relevant part from the output? IMHO, the
> date command is better for this purpose:
>
> DateTime=$(date -r "$Package" "+%Y-%m-%d %H:%M")
>
>
> Nils
>
Thanks for the tip, I had no idea before that the installed date, and
time of a package was available from it's properties alone. I'm not sure
which code example I will wind up using, as they both work great.
Thanks again, Ray Parrish
--
Linux dpkg Software Report script set..
http://www.rayslinks.com/LinuxdpkgSoftwareReport.html
Ray's Links, a variety of links to usefull things, and articles by Ray.
http://www.rayslinks.com
Writings of "The" Schizophrenic, what it's like to be a schizo, and other
things, including my poetry.
http://www.writingsoftheschizophrenic.com
More information about the ubuntu-users
mailing list