Unlike previous labs, this lab should be completed by editing and submitting this HTML file and by submitting scripts and output files.
Submit via all materials by D2L by the end of the lab session.
Given the following word list:
cd ls read for echo ps bind w then declare shift help printf grep
Write a shell script, builtin_for.sh
, that
outputs:
cd is builtin
ls is file
path for ls is /usr/bin/ls
read is builtin
for is keyword
echo is builtin
ps is file
path for ps is /usr/bin/ps
.
.
.
Your script should use type
, which
and a for loop. Use help type
to see any relevant
documentation.
Execute the script as follows to capture the output:
builtin_for.sh > ex1.txt
Submit both the script builtin_for.sh
and
ex1.txt
.
Consider the following script, mkfiles.sh
files=""
for first in x y z ; do
for second in 1 2 3 ; do
files="$files $first$second"
done
done
echo $files
Change this with your answer
Change this with your answer
Consider the following for loop
for i in 0 3 6 9 12 ; do
printf "%5x %6x\n" ${i} $(( i**2 ))
done
Change this with your answer
Change this with your answer
Change this with your answer
while_instead.sh
.Submit as while_instead.sh
.
seq
Consider the following script. Look at the man page for the
seq
command.
seq 0 10 101 | while read i; do echo "$i $(( i*2 + 1))"; done
Change this with your answer
seq
). The script
must produce the same output.Submit the script as seq_alt.sh