<<

Problem Solving and Tools

Command versus Graphical User Interface

• Ease of use

• Interactive exploration

• Scalability

• Complexity

• Repetition

Example: all Tex files in a directory (and its subdirectories) that have not changed in the past 21 days. With an interactive file roller, it is easy to sort files by particular characteristics such as the file extension and the date. But this sorting does not apply to files within subdirectories of the current directory, and it is difficult to apply than one sort criteria a . 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 pages man find or you can execute the command with the – option. In this example, the standard output to the screen is piped into the more command which formats it to dispaly one screenful at a time. Hitting the space bar displays the next page of output, the return key displays the next line of output, and the ”q” key quits the display. find --help | more

Construct Solution in Pieces

• Solve a problem by breaking down into pieces and building back up

• Typing vs automation

• Error messages - experimentation

1 Example: Find all occurrences of a particular string in several files. The command searches the contents of files for a regular expression. In this case we search for the simple character string “/stat141/FINAL” in all files in the directory WebLog that begin with the filename “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* > newfilename

If you want to add the output to an existing file, use ¿¿ for the redirection grep /stat141/FINAL/ WebLog/access* >> oldfilename

Where 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 do things

Example: Someone named Bob sends you a rar file in an email attachment. What do you do 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 “rar linux” yield fruitful results. We then visit the site, download the software, and install it. The command, man rar

2 tells us how to use the rar command. We find that the t option on the command tells us what is inside the rar file. This is very useful because it gives us information about the organization of the rared files. rar t hw.rar

We see that there are several files inside hw.rar and they are not contained in a directory. We make a directory in which we extract the files so they do not clutter up our current directory. Bob Bob rar e hw.rar

Basics 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 packages

3