- The problem statement, all variables and given/known data:
Get each of these programs to run. Prove that you've done this(use script). Give a description of each program along with sample executions.
These are the exact programs we were given.
- Relevant commands, code, scripts, algorithms:
PROG2:
#!/bin/sh
#beginline endline file
sed -n $1,$2p $3
PROG3:
#
set pwrs=(00000000)
@pwrs[1]=1
@next=2
while($next<9)
@last=$next+1
@pwrs[$next]=$pwrs[$last]*2
@next=$next+1
end
@count=1
while($count<=8)
echo $pwrs[$count]
@count=$count+1
end
PROG4:
#!/bin/csh -v
#-fvx
# usage:prog4 [dir(s)]
if($#argv==0) then
set dir="."
else
set dir=$argv[1]
endif
while(1)
if(! -d $dir) then
echo $0 no directory $dir
else
echo $dir
@ fcount=0
@ dcount=0
foreach file($dir/*)
if(-f $file) then
@ fcount++
else if(-d $file) then
@ dcount++
endif
end
echo $fcount files $dcount directories
endif
if($#argv<=1) then
break
else
shift
set dir=$argv[1]
endif
end
- The attempts at a solution (include all code and scripts):
I am not sure how to execute the programs. I attempted to execute them using ./<filename> with the files being prog2, prog3, and prog4 respectively, but I don't know what arguments to pass if any. The programs are written in the vi editor, but I tried writing one program(which is not listed here) using the script command and it did not work. I also don't know how to actually print the results to turn them in, I only know how to use the snipping tool to screenshot.
- Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course)
SUNY Polytechnic Institute, Utica, NY, US, Cavallo, CS307
Any help is greatly appreciated, it is due 10/22 at 12pm EST