using awk on a variable

Ray Parrish crp at cmc.net
Thu Jan 21 15:56:37 UTC 2010


Neil Cherry wrote:
> 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.
>   
Thank you! That worked perfectly! I couldn't figure out where to feed 
the variable to awk, and I didn't think of using echo with the pope to 
get it to work. Thanks again!

Later, 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