Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Extra Credit Assignment: Arrays - Visual Effects Programming | VSFX 160, Assignments of Typography

Material Type: Assignment; Professor: Kaul; Class: Introduction to Visual Effects Programming; Subject: Visual Effects; University: Savannah College of Art and Design; Term: Unknown 1989;

Typology: Assignments

Pre 2010

Uploaded on 08/04/2009

koofers-user-zcb
koofers-user-zcb 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Extra Credit assignment: Arrays
Arrays are a list of strings or numbers and are popular in every programming language,
not just bash. You will need to see their awesome power to fully appreciate what they can
do for you.
Type this in:
names=(Paco Juan Dave Francois Helmut)
echo “The number of elements in the array names is ${#names[@]}”
echo “The first element in the array names has an index of 0 and is ${names[0]}”
echo “The length of ${names[0]} is ${#names[0]}”
for i in ${names[@]}; do
echo “I like the name $i.”
done
# Some more advanced string operators
# Now we can use some string operators on the strings (p.95 of Oreilly book)
# ${varname:offset:length}
echo ${names[0]:0] # This returns paco
echo ${names[0]:0:2] # This returns pa
echo ${names[0]:2] # This returns co
Your assignment: Take this script and see if you can make some innovative use of arrays
in bash scripting. There is an incredible amount of uses for them.

Partial preview of the text

Download Extra Credit Assignment: Arrays - Visual Effects Programming | VSFX 160 and more Assignments Typography in PDF only on Docsity!

Extra Credit assignment: Arrays

Arrays are a list of strings or numbers and are popular in every programming language, not just bash. You will need to see their awesome power to fully appreciate what they can do for you.

Type this in:

names=(Paco Juan Dave Francois Helmut) echo “The number of elements in the array names is ${#names[@]}” echo “The first element in the array names has an index of 0 and is ${names[0]}” echo “The length of ${names[0]} is ${#names[0]}”

for i in ${names[@]}; do echo “I like the name $i.” done

Some more advanced string operators

Now we can use some string operators on the strings (p.95 of Oreilly book)

${varname:offset:length}

echo ${names[0]:0] # This returns paco echo ${names[0]:0:2] # This returns pa echo ${names[0]:2] # This returns co

Your assignment: Take this script and see if you can make some innovative use of arrays in bash scripting. There is an incredible amount of uses for them.