Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Bash shell script that animates the ascii text files. 1) Copy the data f

ID: 3839264 • Letter: W

Question

Write a Bash shell script that animates the ascii text files.

1) Copy the data files from the instructor's home directory by

cp -r /home/students/yuanj/HW9/b ~

2) Your script should take the directory name as the first argument and frames per second as the second argument.

3) Your script animates the ascii files under the directory. An ascii filename is numbered as the order how it appears in the sequence of play. For example, File "1" should be played as the first frame, file "2" should be played as the second frame, and so on. Here is a demo of how your script sample runs should look like:

http://farvlu.farmingdale.edu/~yuanj/teaching/HW9-demo.gif

3) You must use loop, or you receive 0 points.

(There are 21 files in directory b. All the files are numbered from 1 to 21 and if you cat any file in directory b it is the same picture gif but it in in a diffrent position in every file. My proffesor want me to put all those files in a loop so all these files can create a moving gif.)

Hint 1

(

#!/bin/bash -x
#I know the first parameter is the pause sec
#I expect the second parameter is dir name
clear
framenames=`ls $2`
#1 2 3 4 5
for i in $framenames
do
#the file name is actually a/1 a/2
cat "$2/$i";
sleep $1;

clear;

done

)

Hint 2

(

#!/bin/bashi
framenames=`ls $2`
if [ ]
echo $framenames
cd $2
for i in $framenames
do
cat $i
sleep $1
clear
done
cd -

)

Our proffesor gave us this hinyt but she did not finish it. Can someone please finish this bash shell script so I can have what she wants.

Thanks

CP done Isinap8 dfarvlu b)$ 15 10 11 12 13 14 15 16 17 18 19 2 20 21 3 4 5 6 7 B 9 Ising peniarvlu b clear Ising 86farvlu b)% cat 1 LL a V a Type here to search 6013 AM 5/14/2011

Explanation / Answer

Hi

Hint1 is almost the complete script. It's just that framenames='ls $2' dos not work. You can try the following script containing exception handling as well:

#!/bin/bash
clear

if[$2 = ] then

echo "no foldername given"

exit 0

fi

if[$1 = ] then

echo "no frames per second value given"

exit 0

fi

if[$1 -lt 0] then

echo "unreasonable frames per second value given"

exit 0

fi
framenames=$2
for i in $(ls *$framenames*);
do
cat "$2/$i";
sleep $1;
clear
done

Feel free to ask in case of any queires. :)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote