Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Fri Jan 27, 2006 11:56 pm 
Offline
Junior Member

Joined: Fri Aug 20, 2004 10:32 am
Posts: 38
Hey All,

I'm writing up some scripts and I can see advantages to doing what I need to by hacking up a Bash script. In pseudo code this is what I want to do:
Code:
#!/bin/bash
# assume current directory has X number of .txt files
output=`ls *.txt`
read each filename into an array


So for example if the current directory contains "linode.txt cool.txt whatever.txt" I would like to have each of those filenames in an array, for example:
array[0] contains linode.txt
array[1] contains cool.txt
array[2] contains whatever.txt

Is there a simple way to do this? Note that I would prefer not to use awk in this situation as it is going to be used later after I parse out some data. I suppose I could also do this in Perl, but I would like to focus on learning some bash scripting right now.

_________________
-Kevin
thomber.net Directory
http://pingmyhost.net


Top
   
 Post subject:
PostPosted: Sat Jan 28, 2006 12:08 am 
Offline
Junior Member

Joined: Fri Aug 20, 2004 10:32 am
Posts: 38
Ugh, 3 seconds more of searching and I found my answer. (Wish I could delete my posts)

For completeness, I needed to use parens around my command :)

output=(`ls *.txt`)

_________________
-Kevin

thomber.net Directory

http://pingmyhost.net


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group