LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   shell scripting (https://www.linuxquestions.org/questions/programming-9/shell-scripting-64010/)

rch 06-06-2003 09:08 AM

shell scripting
 
Guess I was not good at shell scripting(or not have read enough man pages or books)
What would be the equivalent to the zsh script given below in bash
echo ${${(z) $(whereis libcrypto)}[2]}
if the output of $(whereis libcrypto) is
libcrypto:libcrypto.so libcryto.a

it returns libcrypto.so only.
Sorry for asking a really stupid q!

unSpawn 06-06-2003 09:45 AM

Dunno cuz I ain't using Zsh, but if you know the fixed item is the third, why not just do "i=( $(whereis libcrypto) ); echo ${i[2]}".
If you want to do it in one go you gotta remember Bash does inside-out variable substitution, so I would guess (but I'm no Bash guru either) you would need some wicked "eval" construct.

There ain't no such thing as stupid questions.
NOT asking, that's stupid.

rch 06-06-2003 11:41 PM

Just a followup
I thought that the question was stupid becoz it seemed so easy.
Ever since I started using zsh ,I feel that there is no better shell than zsh.So to do a simple work like the one, I thought that there must be something quite easy in bash.
And thanks for your reply.It works perfectly.I was hoping to check some eval construct.
Thanks again.

rch 06-07-2003 04:10 AM

And I just remembered that I have to use
echo ${i[1]}
not
echo ${i[2]}
Stupid arrays!?


All times are GMT -5. The time now is 08:27 PM.