aspose file tools
The moose likes Linux / UNIX and the fly likes array usage in shell script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "array usage in shell script" Watch "array usage in shell script" New topic

array usage in shell script

ajse ruku
Ranch Hand

Joined: May 06, 2005
Posts: 196

I want to have an array containing all the sub-folder names inside /home/user.
Can anybody suggest how to do this or provide any link ?

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 31634

What do you want to do with that array. In UNIX, we usually pipe the list directly to the next command.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
ajse ruku
Ranch Hand

Joined: May 06, 2005
Posts: 196
Hi Jeanne,
i want to execute a command inside a for loop from i=0 to i=arr_len-1,i.e for each element of the array.
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

Like what Jeanne said, normally we pipe the list to the next command. Anyway, if you want to iterate it, you can do something like this:

SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923
I agree. Here's the link:
subject: array usage in shell script