using awk on a variable

Neil Cherry ncherry at linuxha.com
Thu Jan 21 15:32:40 UTC 2010


On 01/21/2010 08:46 AM, Ray Parrish wrote:
> Hello,
> 
> 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
> 
> The error returned is as follows -
> 
> awk: 592 -rwxr-xr-x 1 root root 601056 2009-01-29 04:51 gedit
> awk:             ^ syntax error

Is this what you want:

  ReturnValue="`ls -als "$Package"`"
  if [[ "$ReturnValue" != "" ]]; then
    DateTime="`echo $ReturnValue | awk '{ print $7, $8 }'`"
    echo "$DateTime"
  fi

Not that I removed return, needed that for my testing.

-- 
Linux Home Automation         Neil Cherry       ncherry at linuxha.com
http://www.linuxha.com/                         Main site
http://linuxha.blogspot.com/                    My HA Blog
Author of:    	Linux Smart Homes For Dummies




More information about the ubuntu-users mailing list