-   Linux - Newbie (
-   -   multiple commands assigned to bash variable (

itzamecwp 02-14-2007 01:00 AM

multiple commands assigned to bash variable

Im tying to assign multiple commands to a variable and having
quite a hard time. Here's how it goes ..

$ pwd

$ A="pwd"
$ $A

$ pwd;pwd

$ A="pwd;pwd"
$ $A
-bash: pwd;pwd: command not found

Heh?! What am I missing here? spacing doesn't seem to help either.

Im running Ubuntu 6.06.1

Thanks in advance.

bartonski 02-14-2007 02:34 AM

I'm not absolutely sure that you can do what you're wanting to do, in the way that you're wanting to do it... the ';' character is going to terminate the current command, and I don't think that you can pack that into a variable, and then unpack it correctly. (I can't quote chapter and verse from the bash man pages, so please take that with a large grain of salt)

What you can do, which is very similar, is create a shell function:


function A()

can be executed ...


$ A

acid_kewpie 02-14-2007 02:34 AM

that's a pretty nasty way of simplifying things... why aren't you using alias? that's exactly what it's for.

itzamecwp 02-14-2007 07:40 AM

Yup! alias did the trick.

Thank you both for such quick relies.

All times are GMT -5. The time now is 08:42 AM.