cs104 S04, lab 2 more UNIX, *?[] I. Multiple arguments, ls with dirs Type "%mv a b d1" and look at the error message. Make small files a & b and directory d1, then try the command again. What did it do? Type "%ls d1" to check. Move them back with one "multiple" mv command. This doesn't make much sense, but try just "%ls a" and "%ls a d1". What is the rule for ls with multiple files/directories? Create c and, for fun, check whether "cat a b c" (3 files!) works. Check whether we can move three files, with "%mv a b c d1", then check d1 to see if it worked. Next check if multiples work for cp and rm: Use a big cp to copy them back home at the same time, then a big rm to get rid of them all. Hopefully you have a, b and c inside of d1. Try "%mv d1 xxx". Are a, b and c still there? Change xxx back to d1 and create new directory d2 (in ~, next to d1.) Type "mv d1 d2" and figure out where a, b and c are now. What is the general rule when moving to somewhere that does/doesn't already exist? II. Paths on multiple arguements, relative paths Use the recursive cp from lab1 to copy ALL of ~cs104/labs/lab2 to your home directory, then look around a bit. a) Directories sec1 & sec2 might look better in a new directory, allsecs (see pictures.) Use two commands (a mkdir and a big mv from part I) to do this. Check it worked, then change them back (also two commands.) PARTIAL MAP OF LAB 2 CHANGE TO THIS --lab2---- ----lab2--- / / \ \ / | \ info.txt sec1 sec2 misc => info.txt allsecs misc | \ / | | \ dogs cats sec1 sec2 dogs cats b) Stay in your home directory and move s13a.csv up to its parent (so it is with info.txt.) Check that worked, then (stay in ~) move it back. Now head into the boondocks to the misc subdirectory. Stay there and do the same thing (move s13a.csv up to its parent, check, then move it back.) When the first arguement uses a path, where does the second one start? c) Relative paths The picture should be the same as when we started. If you like, use a recursive rm and cp to get a fresh one. Go back to the misc subdirectory, and do the same thing as in b), but without using ~. Instead, use enough ..'s to go up. III. Wildcards: *?[] -Go to lab2/sec1 and try these commands: "%ls a.*" "%ls *a*" "%ls ???a*" -Make a subdirectory moved in sec1. Stay in sec1 and write one command, without listing the files by name, to do these things: o Copy files ending in .csv to moved o Delete all files in moved (but do not delete moved) o Move only "s13a.csv s14a.csv s31a.csv s18a.csv" to moved (the s#a .csv files) o Move them back o Copy everything to moved except: s16aaa.csv suba.dat (Use ? to check for 4 letters) o Delete from moved only the files in the teens (13-18, all but s31a.csv) -Go to lab2 and show (use ls) all filenames in sec1 or sec2 that end in .csv. You will need to use * in _two_ places along the path. -What does "%ls s13[ab].csv" do? "%ls [sg]*"? "%ls [tgs]*[ab]*"? In general, what does [] do? -Use [] to write a command that will show all filenames in sec1 that have 13,14,15 or 16 after the first letter (but not 17, 18 or 19.) -Write a command to show all filenames in lab2 that start with an s. Hmmm...it doesn't quite work right. Find the ls option that fixes this (it is near the top.)