Lab 1 - FL13 - ECE 198 JL - University of Illinois - Engineering Wiki

Ls suppos e we want to k now the c ontents of a direc

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: story, and the left/right arrow k ey s to move y our c urs or and modify the c ommand before res ubmitting it for ex ec ution. This tric k bec omes us eful when y ou want to run a s eries of s imilar c ommands , lik e in the following s ec tion. ls Suppos e we want to k now the c ontents of a direc tory . The ls program (s hort for "lis t direc tory c ontents ") is des igned to do ex ac tly that. It c an tak e z ero or more arguments : l [ietr].. s drcoy . If run with no arguments , it jus t lis ts the c ontents of the c urrent work ing direc tory : [aap2lnx ~$l kcmb@iu3 ] s pr1 ntstt at oe.x If run with arguments , it interprets the arguments as direc tories and lis ts the c ontents of thos e direc tories . [aap2lnx ~$l pr1 kcmb@iu3 ] s at fott o.x The direc tory argument is ac tually a pa th. W ith no leading "/" c harac ter it is a re la tive pa th, meaning that it is followed relative to the c urrent work ing direc tory . W e c an als o us e abs olute paths : l /oekcmb s hm/aap2 In eac h direc tory , there are als o s ome s pec ial direc tories to help y ou navigate the files y s tem, but they are hidden by default (on the GUI as well as the CLI). To s how them, we run ls with "-a" as an argument: lsa Single c harac ter arguments prec eded by a "-" c harac ter are c alled fla gs. They are us ed to modify the behavior of a program. In this c as e, the "-a" flag tells ls to s how hidden files and direc tories . In Unix , thes e are any files or direc tories that s tart with a "." c harac ter. You will s ee output lik e the following: . . . .db aoe .ahhsoy bs_itr .ahpoie bs_rfl .ahc bsr pr1 at W e're interes ted in the firs t two entries , the res t are hidden c onfiguration files us ed by programs running on the s y s tem. The firs t direc tory is c alled "." It alway s c irc ularly referenc es the direc tory that it's in. This may s eem s trange, but it c an be us eful. For ex ample, if ls didn't work without any arguments , we c ould s till lis t the c ontents of the c urrent work ing direc tory with: l. s The s ec ond entry is "..", whic h is a referenc e to the pa re nt dire ctory. This is the direc tory whic h c ontains the direc tory that it's in. W e us e this entry to navigate down the files y s tem tree toward the root. Let's s ee what happens when we pas s it as an argument to ls: [aap2lnx ~$l . kcmb@iu3 ] s . alnu brkt ca1 oix2 aaa2 he4 alws bmoe ceg8 pei2 mor hn8 fee3 eny gmil abl hag6 kcmb mto1 odn1 un16 aap2 irs lai hf1 uf0 kros mrwr pr39 ukw1 toe2 ak7 teen wn49 dlo2 ag2 tasn wae2 hne3 fgn This look s lik e a lis t of other people's home direc tories , whic h mak es s ens e s inc e we were in /home/k ac ampb2 s o the parent direc tory is /home. Mak e s ens e? Let's play with s ome fanc ier paths . Try the following with ls : l/ s l ./.hm s ../oe l pr1. s at/. l .pr1. s /at/ l ./.hm/.hm s ../oe./oe l ..pr1..//../ s //at//.../. Can y ou ex plain how eac h path is evaluated? Be s ure to as k for help if y ou don't unders tand. It's helpful to us e ls often. It's alway s good to verify the c ontents of y our c urrent work ing direc tory . cd If we want to go to another direc tory , we us e the cd program, s hort for "Change work ing direc tory ". The s y ntax of c d is s imply : c drcoy d ietr For ex ample, to go into the part1 direc tory and lis t the c ontents , we c an do: c pr1 d at l s Now what happens wh...
View Full Document

Ask a homework question - tutors are online