Supressing an error message in bash script
Ray Parrish
crp at cmc.net
Sat Dec 12 03:23:50 UTC 2009
Neil Cherry wrote:
> On 12/11/2009 09:40 PM, Ray Parrish wrote:
>
>> function ArrayLoad {
>> PackageData=`"dpkg -p gedit"` 2> /dev/null
>>
>
> Try it without the double quotes. Does that do what you want?
>
Wirhout the double quotes nothing gets loaded into the array.. Also
nothing gets loaded into the array with my original code, as the output
thst I thought ewas being generated by that function, was actually being
output by the following function which works very nicely. I had
forgotten to comment out it's call in my test code so it was generating
the loop output before the only output of the first function I quoted
which was the error message.
# Test array assignment from variable line by line
function ReadintoArray {
PackageData=`dpkg -p gedit`
LoopCount=0
while read ThisLine; do
Data[$LoopCount]="$ThisLine"
echo "$LoopCount - ${Data[$LoopCount]}"
(( LoopCount++ ))
done <<<"$PackageData"
}
I guess I'll go with this second version which works great, unless
someone can tell me how to load the array with a single call like I was
trying in the other function. Just looking for the most efficient way to
get the data into the array line by line.
Later,Ray Parrish
--
The Future of Technology.
http://www.rayslinks.com/The%20Future%20of%20Technology.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