-   Programming (
-   -   how execute a command in a list of commands (

bkcreddy17 06-24-2009 08:08 AM

how execute a command in a list of commands
Hi i am not expertise at shell script, can anybody clarify my doubt?
I have a which contains list of commands, say

How to execute cal command out of them?
Thanks in an advance......:)

colucix 06-24-2009 08:21 AM

Well, I'd simply type

What is the reason to retrieve the command from a list, if you already know which command it is? Or have you some criteria to choose cal and not - for example - date or ls? What are you trying to achieve?

bkcreddy17 06-24-2009 09:01 AM

Actually i will execute a long shell script using cron job. It contains mysqladmin command to change the password,say

mysqladmin -u root -pXXXXX password YYYY
where XXXXX is actual password and YYYY is new password. And i cant remember these complicated passwords. Some times i need to execute this particular command/line in that huge script file. We can get that line by

grep "mysqladmin - root"
but how to execute it with grep combination?

colucix 06-24-2009 09:07 AM

It does make sense now. Have you tried this?

$(grep "mysqladmin -u root"
it does command substitution then executes the resulting command line.

bkcreddy17 06-24-2009 09:21 AM

Got it, Thank you colucix.

All times are GMT -5. The time now is 02:47 PM.