-
Website
http://www.tech-recipes.com/ -
Original page
http://www.tech-recipes.com/rx/635/bash-shell-script-declaringcreating-arrays/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
davak
83 comments · 1 points
-
Web Design
3 comments · 1 points
-
danishbacker
9 comments · 1 points
-
flexinfo
11 comments · 1 points
-
Tonychelle
4 comments · 1 points
-
-
Popular Threads
-
Symfony: Drop Down List Box Without Submit Button
18 hours ago · 1 comment
-
PowerPoint 2010: How To Convert a Presentation to Video (WMV format)
1 week ago · 1 comment
-
Windows Live Mail: Automatically Spell Check All Email Before Sending
1 week ago · 2 comments
-
Firefox: How to Make Google Reader the Default RSS Reader for Subscribing to Feeds
1 week ago · 1 comment
-
Facebook: How To Get Only Status Updates on Your FB Home Page
1 month ago · 4 comments
-
Symfony: Drop Down List Box Without Submit Button
for foo in $(find -type f -iname "*.png" -printf "%fn"); do
file[${#file[*]}]=$foo
done
will create an array of all png files
set -A array_example 1 2 3 4 5
i=0
echo ${array_example[$i]}
#existing array
existing=(item1, item2, item3);
#items to merge (including an item requiring correct quoting)
merge=(item4 item5 "${item6}*");
count=${#existing[@]};
num_new_items=${#merge[@]};
# this loop appends items to the end of the array
for (( i=0;i<$num_new_items;i++)); do
echo ${i};
existing[$count]=${merge[${i}]};
let count+=1;
done
count=${#existing[@]}
for (( i=0;i<$count;i++)); do
echo ${existing[${i}]};
done
You can do it this way:
<pre>
cat $file | while read line; do
echo "$line";
done
</pre>