LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 06-06-2003, 10:08 AM   #1
rch
Member
 
Registered: Feb 2003
Location: Santa Clara,CA
Distribution: Mandriva
Posts: 909

Rep: Reputation: 48
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!
 
Old 06-06-2003, 10:45 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,699
Blog Entries: 54

Rep: Reputation: 2962Reputation: 2962Reputation: 2962Reputation: 2962Reputation: 2962Reputation: 2962Reputation: 2962Reputation: 2962Reputation: 2962Reputation: 2962Reputation: 2962
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.
 
Old 06-07-2003, 12:41 AM   #3
rch
Member
 
Registered: Feb 2003
Location: Santa Clara,CA
Distribution: Mandriva
Posts: 909

Original Poster
Rep: Reputation: 48
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.
 
Old 06-07-2003, 05:10 AM   #4
rch
Member
 
Registered: Feb 2003
Location: Santa Clara,CA
Distribution: Mandriva
Posts: 909

Original Poster
Rep: Reputation: 48
And I just remembered that I have to use
echo ${i[1]}
not
echo ${i[2]}
Stupid arrays!?

Last edited by rch; 06-07-2003 at 05:51 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 03:14 AM
shell interface vs shell scripting? I'm confused jcchenz Linux - Software 1 10-26-2005 04:32 PM
Shell Scripting again yaadhav Linux - Newbie 8 08-04-2005 11:21 AM
shell scripting pcdebb Linux - Newbie 17 11-20-2003 04:49 PM
shell scripting markus1982 Linux - General 2 05-20-2003 08:42 AM


All times are GMT -5. The time now is 09:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration