creating variables

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Nathan England
Date:  
Subject: creating variables
It seems I jumped the gun again. This doesn't accomplish what I had hoped. I
went home for lunch and looked at my script and realized that's not what I
wanted..
I'll explain a bit more.

I have a script that takes user input. The user input is $2 because initially
the script requires a command which is $1 looks like this:

#>script command input

Currently I'm working on the status command. When I type script status input I
want it to search for whatever I put in as input..

#>script status mysql

It then searches /var/log/packages for mysql, but it is actually
mysql-3.23.52-i386-1


Once it finds this, I need it to put that full name back into another variable
That way I can cat /var/log/packages/$VARIABLE

I tried doing

PACKAGE=`ls /var/log/packages | grep $2`

it comes back saying there are too many commands in my if statement or grep
displays its help menu...

I tried doing
if [ -f /var/log/packages/$2* ]; then
PACKAGE=`ls /var/log/packages | grep $2`
echo $PACKAGE
fi
but it either says I have a problem : ]: with my if statement or grep displays
its help menu.

Any ideas?
How can I accomplish this?


On Friday 30 August 2002 09:18 am, Nathan England wrote:
> I want to search a directory for a file name and throw it into a variable.
> Such as:
>
> /var/log/packages/mysql-3.23.51-i386-1
>
> I want to type in just mysql and have it create a variable for
> mysql-3.23.51-i386-1
>
> I was trying
> ls /var/log/packages | grep mysql
> but from there don't know how to get it into a variable
>
> And
> VARIABLE='ls /var/log/packages | grep mysql'
> doesn't work either.
>
> I have a script that searches for whatever I tell it.
>
> myscript something
>
> Something is a variable, but I type in a partial name, like mysql and it
> searches and prints the full name in the variable which would be $1 or $2
> or $3 whatever...
>
> How do I accomplish this in bash?
>
> nathan
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> PLUG-discuss mailing list -
> To subscribe, unsubscribe, or to change you mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss