More Unix magic
Bash: copying, moving, removing files
cp source.txt dest.txt: create a copy of one file with a new name.mv old.txt new.txt: move (re-name) a file.rm junk.txt: remove (delete) a file.mkdir newfolder, rmdir oldfolder: commands to create and remove folders.
Bash: examining file contents
more myfile.html, cat myfile: 'more' usesb, [space], qjust like a man page.head bigfile.txt, tail bigfile.txt: Shows just the beginning (or end) of a (usually very long) file.grep some\ text\ to\ search\ for *.html: Do any files ending in .html contain the (case sensitive) text 'some text to search for'?
Bash: power of the command line
[up arrow], [down arrow]: Step backwards (forwards) through the history of recently issued commands.[ctrl]-a, [ctrl]-e: Move to the beginning (end) of the current command.[tab]: Command line completion based on file names. For examplels \et[tab]should leave behindls \etc. Bash looks for a unique completion, and if it doesn't find one, a second [tab] will show all possible completions.
Emacs: Moving text around
[ctrl]-k, [ctrl]-y: kill one, or more than one lines (send the text to the 'kill buffer', sort of like the windows clipboard), move somewhere else in the file, then yank back what you killed.[ctrl]-x 2, [ctrl]-f {filename}: split the editing window in two, then load another filename in one of the windows. Switch to the other window with[ctrl]-x o, and revert back to just one window with[ctrl]-x 1
You can also use OS-X copying (⌘-c) and pasting (⌘-v). (Why not cutting??). And you can use OS-X commands [shift]-⌘-[plus] and ⌘-[minus] to enlarge and shrink windows.
Bash: Background / Foreground
Within any running program (including editing a file with emacs) you can suspend the currently running program with [ctrl]-z, placing it in the 'background'. You'll find yourself back at the command-line prompt.
Return to a previously suspended program by issuing the foreground command:
fg
When you eventually exit bash to finish up your session, you'll be reminded if you have still have background items.
Unix toolbox philosophy
The toolbox philosophy means writing many small utilities that can be chained together (today: 'mash ups') to do powerful things. For example, with a text file named 'junk' that contains three lines:
$ cat junk 1 the first line 3 line numbered 3 2 the second line $ cat junk | sort |more 1 the first line 2 the second line 3 line numbered 3
Pipes and re-direction
Most Unix utilities respond to commands from the keyboard, or 'stdin'. But using the pipe operator | in the previous example, they can get their input from other sources (a text file, or the output from another utility) instead.
You can use the redirection operator > to send the output of a utility to a file instead of to the screen ('stdout') like this:
$ cat junk | sort > sortedfile $ cat sortedfile 1 the first line 2 the second line 3 line numbered 3