Iterating over a file is a good example, or running something as a different user in the same window session. Here's a stupid example: Say you want to open 100 web pages at a time in a browser, all in different domains. You have a file that contains all the URLs for these, but copy-pasting them into the address bar just takes a blasted long time. >From the terminal do:
for f in `cat UrlFile`; do firefox $f ; done and you'll open up every url in firefox in a matter of seconds. Another thing you can do with a linux shell that is difficult to do in a gui is run something as a different user. Say you have two gmail accounts and only one web-browser. Well, make a new user on your system, and from a terminal: xhost localhost sudo -u otheruser -H firefox and now you have two independent sets of credentials to play with. The terminal also has some incredibly powerful text-editing tools built into it. Say you're working on a code project, and you find that you and a partner replicated some functionality, and his works better, and now you want to call his function instead of your own--problem is, it's called across multiple files. Not a problem in the shell, just do a: sed -i 's/myFunction/hisFunction/g' * and all the files in your directory will do a search and replace (regex can be used here too). Finding the contents of the file is much much easier in the terminal as well. Say you want to find every instance of the word "Error" in a directory structure recursively, well, that's just: grep -ir "Error" * and it'll tell you where that is found by file name, and line, and output that exact line. Most of the servers in the world don't have a gui on them either, so if you do any kind of system administration or high-performance-computing, then using a GUI just isn't an option. -- Todd Millecam
-------------------- BYU Unix Users Group http://uug.byu.edu/ The opinions expressed in this message are the responsibility of their author. They are not endorsed by BYU, the BYU CS Department or BYU-UUG. ___________________________________________________________________ List Info (unsubscribe here): http://uug.byu.edu/mailman/listinfo/uug-list
