Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problems with my script. I'm keep getting this error: I'm pretty sure there's something wrong with the project2.24.out file because the file does not recongized

Problems with my script. I'm keep getting this error:image text in transcribed

I'm pretty sure there's something wrong with the project2.24.out file because the file does not recongized it, only the project2.12.output does

Here's the code:

if [ `echo $1 | grep -c "24" ` -gt 0 ] #check if command line argument contains 24 or not

then

out_file=project2\.24\.out #set the out file to project2.24.out

current_time=`date +"%D %H:%M:%S"` #format the time to 24 hour format

else

out_file=project2\.12\.out #set the out file to project2.12.out

current_time=`date +"%D %I:%M:%S %p"` #format the time to 12 hour format

fi

echo "**************">$out_file #write the line to file in write mode so that file would get created or replaced

echo "">>$out_file #write the line to file in append more so that the line gets added in end of the file

echo "Student name : Mark James">>$out_file #write the line to file in append more so that the line gets added in end of the file

echo "Project 2 CIS 129 Sec #">>$out_file #write the line to file in append more so that the line gets added in end of the file

echo $current_time>>$out_file #write the line to file in append more so that the line gets added in end of the file

echo "Student name : Mark James">>$out_file #write the line to file in append more so that the line gets added in end of the file

echo "Name Oncall Phone Start Time">>$out_file #write the line to file in append more so that the line gets added in end of the file

echo "**** ****** ***** **********">>$out_file #write the line to file in append more so that the line gets added in end of the file

echo "">>$out_file #write the line to file in append more so that the line gets added in end of the file

i=0

result[0]=""; #declare empty array to hold lines to be written to output file

while read line #read lines from project2.1.input

do

read first second

while read line1 #read lines from project2.2.input

do

read third forth fifth

if [ `echo $first | grep -c $third ` -gt 0 ] #if name from line in first input file matched with name in line of second input file

then

if [ `echo $1 | grep -c "24" ` -gt 0 ] #if 24 hour format time is requested through command line argument

then

fifth="$fifth hours" #add 'hour' to the time

elif [ $fifth -gt 11 ] #if hour is greater than 11

then

fifth=`expr $fifth - 12` #deduct 12 from time

fifth="$fifth PM" #it's PM

else

fifth="$fifth AM" #it's AM

fi

result[$i]="$first $forth $second $fifth" #Add the line to result to be written to output file

i=`expr $i + 1` #increase the value of i by 1

fi

done

done

days=(Monday Tuesday Wednesday Thursday Friday Saturday Sunday) #declare array containing days in week

for day in "${days[@]}" #for every day in days array

do

for line in "${result[@]}" #for every line in result

do

read first second third forth fifth

if [ `echo $day | grep -c $second ` -gt 0 ] #if day in days array matched with day maintained in line

then

echo "$line" >> $out_file #write the line to file

fi

done

done

Can anyone help? I've been stuck on this part for a while.

./project2.sh 24 Usage: grep [OPTION]... PATTERM rry -grep-help' for more information. Usage: grep [OPTION]. . PATTERN [FILE]. Try 'grep --help' for more informatio Usage: grep [OPTION]. .. PATTERN [FILE]... Try 'grep -help' for more information Usage: grep [OPTION]. . PATTERN [FILE]... Try 'grephelp' for more information Usage: grep [OPTION].. . PATTERN [FILE]. . . Try 'grep-help' for more information. Usage: grep [OPTION]. . . PATTERN [FILE]. .. Try "grep-help' for more information Usage: grep [OPTION]... PATTERN [FILE]... Try 'grephelp' for more information [FILE]. . . ./project2.sh 24 Usage: grep [OPTION]... PATTERM rry -grep-help' for more information. Usage: grep [OPTION]. . PATTERN [FILE]. Try 'grep --help' for more informatio Usage: grep [OPTION]. .. PATTERN [FILE]... Try 'grep -help' for more information Usage: grep [OPTION]. . PATTERN [FILE]... Try 'grephelp' for more information Usage: grep [OPTION].. . PATTERN [FILE]. . . Try 'grep-help' for more information. Usage: grep [OPTION]. . . PATTERN [FILE]. .. Try "grep-help' for more information Usage: grep [OPTION]... PATTERN [FILE]... Try 'grephelp' for more information [FILE]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions

Question

8. Satyam Computer Services Limited

Answered: 1 week ago

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago