/courses/cs100/cs197u/USERNAME. Make sure to replace USERNAME with your Edlab id.
/courses/cs100/cs197u/cs197u/assignments/assign-4into your 'assign-4' directory. Change to your assign-4 directory. 3. Edit the
script.shfile to make it print out the name of each file in the
datadirectory using a
forloop. 4. Run your script. The output should look something like: elnux7> ./script.sh data-1.txt data-2.txt data-3.txt Note: (1) The script should not have the hardcoded names of the data files. Instead, the script should figure out what files are in the data/ directory on its own. (2)It is also fine if it prints out something like "data/data-1.txt" as the name of each file.
avg.awkfile so that it will print out the average for the second column of the input file. 2. Run your script. Verify that the output of your script is correct: elnux7> awk -f avg.awk data/data-2.txt Average: 1204848 elnux7> awk -f avg.awk data/data-3.txt Average: 16108.6
script.shand call it
script2.sh. 2. Modify
script2.shand make it so that after printing out a filename, it will call the awk script on that file. 3. Run the script. As a result, you should get output like: data-1.txt Average: 30 data-2.txt Average: 1204848 data-3.txt Average: 16108.6 3. Save the output into a file named
script2.shand call it
script3.sh. 2. Modify
script3.shand make it so that after printing out a filename and the output of the awk script on that file, it will rename the file into "mydata-[number].txt" instead of "data-[number].txt" (current format). Print out the new file name right after the average output. 3. Run the script. As a result, you should get output like: data-1.txt Average: 30 data-1.txt renamed to mydata-1.txt data-2.txt Average: 1204848 data-2.txt renamed to mydata-2.txt data-3.txt Average: 16108.6 data-3.txt renamed to mydata-3.txt 3. Save the output into a file named
badscript.bashsuch that the output only contains 4 lines and looks something like: Hi there 197U Student! Right Right Hi tian! Today is Sun Oct 4 11:12:46 EDT 2015 Note: Follow the instructions inside the badscript.sh.
I will collect all these files directly from
???.???Hint: This is a result of fixing Part 5.
lsas in Assignment 2.