Unformatted text preview:

Problem Solving and Unix ToolsCommand Shell versus Graphical User Interface• Ease of use• Interactive exploration• Scalability• Complexity• RepetitionExample: Find all Tex files in a directory (and its subdirectories) that have not changedin the past 21 days. With an interactive file roller, it is easy to sort files by particularcharacteristics such as the file extension and the date. But this sorting does not apply to fileswithin subdirectories of the current directory, and it is difficult to apply more than one sortcriteria at a time. A command line interface allows us to construct a more complex search.In unix, we find the files we are after by executing the command,find /home/nolan/ -mtime +21 -name ’*.tex’To find out more about a command you can read the online man pagesman findor you can execute the command with the –help option. In this example, the standard outputto the screen is piped into the more command which formats it to dispaly one screenful ata time. Hitting the space bar displays the next page of output, the return key displays thenext line of output, and the ”q” key quits the display.find --help | moreConstruct Solution in Pieces• Solve a problem by breaking down into pieces and building back up• Typing vs automation• Error messages - experimentation1Example: Find all occurrences of a particular string in several files. The grep commandsearches the contents of files for a regular expression. In this case we search for the simplecharacter string “/stat141/FINAL” in all files in the directory WebLog that begin with thefilename “access”. We cover regular expressions in more detail later.grep /stat141/FINAL/ WebLog/access*To put these results into a file, we can redirect the output from grep to a new file as follows:grep /stat141/FINAL/ WebLog/access* > newfilenameIf you want to add the output to an existing file, use ¿¿ for the redirectiongrep /stat141/FINAL/ WebLog/access* >> oldfilenameWhere to Begin• People– Ask precise questions– Provide environment information– Use mailing lists• Web resources– www.google.com– internet tutorials• Online documentation - man pages• Invest in the future - Take the time now to learn alternative (and better) ways to dothingsExample: Someone named B ob sends you a rar file in an email attachment. What do youdo with it? One approach is to get on the internet and use the Google search engine,www.google.com, to search for information about rar files. Search keywords such as “rarlinux” yield fruitful results. We then visit the site, download the software, and install it. Thecommand,man rar2tells us how to use the rar command. We find that the t option on the command tells uswhat is inside the rar file. This is very useful because it gives us information about theorganization of the rared files.rar t hw.rarWe see that there are several files inside hw.rar and they are not contained in a directory. Wemake a directory in which we extract the files so they do not clutter up our current directory.mkdir Bobcd Bobrar e hw.rarBasics for Class• login to the machines in SCF• file handling: saving, deleting, finding• file editing: text editors• different file formats• transfer files between home computer and machines in SCF• pull up graphics device remotely• how to get help• shells, flow control, environment variables• installing software, e.g. R


View Full Document
Download Problem Solving and Unix Tools
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Problem Solving and Unix Tools and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Problem Solving and Unix Tools 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?