This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Linux / UNIX and the fly likes store the output of Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "store the output of "find" command in a variable?" Watch "store the output of "find" command in a variable?" New topic
Author

store the output of "find" command in a variable?

shield kumar
Greenhorn

Joined: Feb 05, 2009
Posts: 28
how to store the output of "find" command in a variable inside a shell script?
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11730
    
116

Try:

The variable $FILES will now contain a list of all the files, directories, links ... in your home directory and sub-directories.


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17030
    
  26

There's also an alternative notation that's common:

FILES=`find . name "*.pdf"`

Note that the delimiter for the command string is the "backtick" character, sometimes known as "left apostrophe". It's not the same thing as the normal (right) aprostrophe. On many keyboards, it's located to the left of the "1" key. In my case, it's on the same key as "~".


An IDE is no substitute for an Intelligent Developer.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Tim Holloway wrote:Note that the delimiter for the command string is the "backtick" character, sometimes known as "left apostrophe". It's not the same thing as the normal (right) aprostrophe.

That's one reason why it's deprecated: confused by beginners.

The second reason is, is, it is hard to nest Commands with backticks, but easy with brackets.


http://home.arcor.de/hirnstrom/bewerbung
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: store the output of "find" command in a variable?
 
It's not a secret anymore!