using awk on a variable
Nils Kassube
kassube at gmx.net
Thu Jan 21 14:53:10 UTC 2010
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
More information about the ubuntu-users
mailing list