-
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
-
Facebook: How To Get Only Status Updates on Your FB Home Page
1 week ago · 4 comments
-
Firefox: Enable Case Sensitive Searches When Using Find (Ctrl+F)
4 days ago · 1 comment
-
Windows 7: How To Disable Live Preview for Taskbar Thumbnails
1 week ago · 2 comments
-
Gmail: How to block a sender from your inbox
2 weeks ago · 3 comments
-
Our first iPhone game GreenThumb available in the App Store
3 weeks ago · 2 comments
-
Facebook: How To Get Only Status Updates on Your FB Home Page
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>