• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

array usage in shell script

 
ajse ruku
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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 ?

Thanks
ajse
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34073
335
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ajse,
What do you want to do with that array. In UNIX, we usually pipe the list directly to the next command.
 
ajse ruku
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
regards,
ajse
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic