$30
Task0 :Lo g in a n dP re pa rea directory
First,lo ginto a machine running L in u xandl aunc h aT e r m ina l window a s described inpr ev iou sho m ew o rk s .
We h avesetup aZ IP archive full o f support files th aty o u mus tdownl o ad toyourLinux machine. Download/unzip it to a directoryon y o ursystem. Wesug g e stcreating ah w 5 directory for your fi l e sfo r th isas si gnm ent.
wgethtt p ://co ur ses.c s .w a s hi ng t on . edu / c o u r se s / c s e 3 9l / l9 a u/ h o me w o r k / 5 /hw 5 . z i p un z i phw5.zip
Task 1: Getting Comfortable Wit ha Text Edito r( C op y+ Cu t+ Paste)
The following areex er ci se sand questions are meant to help y o ub ec o me more comfortable w itha text editor th atis built intothe command line. You can choose eitherv imorem ac s.I t doe sno tm atterwh ich e ditory ouc h o o s e , but w e recommend that you pick one and s tickto learning it for the remaindero f th equ arter . While the answers to the questions th emse lve sar e re l ative lyeas yto findb y simply looking th emup , the real learning will come from you actually pr a cticin gt h e s e commands you r s el f.Whi le w e won't b e able to know whether you've reallybe enpra cti cing ,th i si sno t for ourben e fit ,it ' sfor y o urs .W e also recommend getting evenmo rep ra cti ce by writingthe answers toy o urta s k 1 .shand task 1 .shfil e su s ing this e ditor©
1 .Whatisthecommandtocut o r delete 5 lines o f text, starting from your current cursor position? 2.Whatisthecommandtop a s te the 5 lines o f text you just cut in the previous question?
3 . What i s the command to copy 8 lines o f text, starting from y o urc urr ent cursor position? Task 2:Bas hs h e l lcom ma nds
For eac hitemb elow, determine asingl e bash shell statement that willp erform the operation(s) r e q ue st ed.Each solution must b eaone -lineshellstatem ent,butyo um ay use o per ato rss uc h as >,> > , <,I,& & ,and ;.For al lcomm ands , donot c re ateany fil esex c ept tho seindicate d .
To test your commands, yoush oul d have unzipped hw 5 . zip into the c urrentdire ctory . You can assume you arein the h w 5 directory when doingth e s eprobl em s . Use ma np age s orth eLinux Pocket Gu ide ,or post onth e c our seme ss ag e bo ar d,if y ounee d help.
In response toe ac h question,y ouwi l lpr ovidet h e c o m m a n dt h atw ill perform t h eta s k d e s c ribe d ,nottheoutput that the command produces. Wr iteyour commands inon theindic ate dl ine sinthet a s k 2 . s h fileinthehw5 folder.
4 . Write a singleline (this c o ul dbesever al c omm andsbutal ltyp e don one line) that 1 ) creates a directory called Hw 5 ou tpu tinyourc urrentdirec tory , 2) compiles Fresh. j ava,and3 )if itc o mp il e s successfully, runs the program, s endingit s outputintothe file output. t x tin the H w5ou t p u tdirec to ry .H int :r em emberw ehave ways torunmo reth anon e command on a single l ine.E ac h s tepo fth epr oc es s sh ou l donlyoc c uri fth epr evio u s
step(s) succeeded. (Part o fth e difficulty i sinach i ev ing all of th iswitha single-line command: creating a
direc tory ,c o mp i ling ,an d running. O nc eyourco mm andw o rk sfor av al i d F r e s h.j a va,te s t it fo ra bad program by making ac opy ofF re sh .j a v a andeditingit to ins erta s yntaxerror .)
(continued o n next page)
5.Th e Java pr o grams to re d in Box. class readstext from standard input and surround sit w itha text box. I t also requires a command-line p a r a m et e ro f the character to use for the boxe dge s. Write as ing l e l inecommandthat runs the program insu c ha way that it u s esth e character A,for this p ar ameter.Th i s s ingl el inecomman d should alsor e dire c tth epro gr am' sstandard input to come from the input file box input. txt (no teth e sp ac ein the file
name), and make it write its output to the file b o xo u t p u t.t xt inth e current directory. I f sucha file already exists, appendth eoutputto the end o f thi sfi l e rather than overwriting.
6 . ( a) C reatea new empty file who senam e i s thesam e a swh atever u s eri s running the c o mmand .In otherw or ds,if userb il l y b o b ranth i s c omm andfro mdirectory -- / 3 91 / hw 5 ,itwoul d create an emptyfil e named billybob w ith aful l path o f: --/391/hw5/billybob.
(b)Repeat th eabov e,butcreate the file with a .txt e xtens i on,a sinbillybob. txt.
7.(Self-Dis covery)Theyescommand repeate dlyoutputsthe s tringy;itisuse ful only whencombin edwithoth er commandsth at expec ttheuser toc o nfirmmany a ctionsbytypingyorn.
(a)Writeacommandthatruns theJava programQu estions.c la s sand automatically answers ytoal l its questions.
(b)Writeas econdver s ion th atan s wer s nto all th equestions .( Ify oudoit correctly, th ey or n text won't appear onthec o n sole.)Lookingatthemanp ag efo rtheye s command w il lbe use fulhere.
8 .Write a c omm andth atc ompil es all of thejav afil esin yourc urr ent directory andallit s s ub directori es(and sub- sub -directorie s ,etc.re cursiv ely )
9 . Thecur lcomm and fetch esthec ontents ofado c ument at a giv enURL. Whi l ew g e t downlo adsand s av esthe fi letoyourloc aldi s k ,cu r linstead outputsittothe terminal. I nlecture #4 ( fromO c tober 2 2),w ewrotea comm andto p ro ce s sth e htm lfromth e CSfaculty w ebs iteand extr ac tthefaculty emails. Thisco mmand read fromafile thatZo r ah had downl oadedahe adof time.
Mo difyth e co mmandfro ml ectures oth at ina singl eco mmand youfetch th ehtm lfr om http s ://www .cs.wa s h ingto n . edu/pe op le/ faculty,extrac t thefaculty em ai l sfromth e html,andb o thoutp ut the emails to th eterm in ala s well a sw rite themtoa fil ec all edf acult y- e mails.t x t .
Note: You sh ou ldalso find theappropriate command- linear gument(s)tosuppr es ssom eo f c u rl ' sno rm aloutput and run it in" s ilent mode".