LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 05-09-2009, 08:53 AM   #1
alpha883
LQ Newbie
 
Registered: Apr 2009
Posts: 9

Rep: Reputation: 0
Wink to make a script or is there a command for this??


I am executing the find command to find, for example "eclipse" and it's listed in 4 of my directories. The eclipse binary is only in the second directory listed.

Out of the 4 directories I want to cd into the second directory from either a script or a short command line.

I can do "ls $(find . -name eclipse -print)" to ls the contents of the 4 directories but I'm not sure if I can iterate a for loop 4 times through a pipe and just cd $2?

Is this possible?

Thanks
 
Old 05-09-2009, 09:33 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
why don't you use "which" to find the binary?

Code:
which eclipse
 
Old 05-09-2009, 09:45 AM   #3
jan61
Member
 
Registered: Jun 2008
Posts: 235

Rep: Reputation: 47
Moin,

Quote:
Originally Posted by repo View Post
why don't you use "which" to find the binary?

Code:
which eclipse
and to cd into the directory:
Code:
which eclipse && cd `dirname \`which eclipse\``
This works only if eclipse is installed in a path listed in $PATH.

If not (like in my installation too) you can use GNU find:
Code:
cd `find . -name eclipse -type f -printf "%h"`
or any find:
Code:
cd `dirname \`find . -name eclipse -type f -print\``
Jan
 
  


Reply



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
My error in mkisofs command to make a command line iso mg92865 Linux - Newbie 1 06-20-2008 11:43 AM
How do I make a simple script and make it run on bootup?? coolblue Programming 5 12-18-2006 09:55 PM
can i make a script or program make a phone call? nephish Linux - Software 2 08-15-2005 09:02 PM
I accidentally deleted make file in /usr/local/bin, now cannot use make command.... Niceman2005 Linux - Software 2 11-17-2004 07:55 PM
make: cc: command not found make: *** [gzip.o]error 127 zyjk Linux - Newbie 5 02-08-2002 09:58 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:19 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
Open Source Consulting | Domain Registration