HOME: /home/web/dl (press 'd') DATABASES: /home/db (press 'b') ID GUIDES: /home/web/dl/nh/id/20q (press '2') USERS: /home/users (press 'u') IMAGES: /home/IM (press 'i') CHECKLISTS: /home/web/dl/nh/cl (press 'c') TAXA: /home/web/dl/nh/tx (press 't') INDEX: /home/IN (press 'n') PROGRAMS: /home/users/programs (press 'p')
COMMANDS OUTSIDE A FILE (Unix commands)
^C stops whatever command is in process and starts you over bak backs file vi views file cd change directory cd .. changes directory up a level md makes a directory dir lists files in directory ls lists files in directory (takes up less space than 'dir') mv move EX: mv day.txt night.txt, you just changed the name of the file EX: mv day.txt /home/users/l/Lewis,_CS, you just moved day.txt into CS Lewis' directory cp copy EX: cp day.txt night.txt, you just made a file called night.txt that is identical to day.txt EX: cp /home/web/dl/day.txt . , you just copied day.txt to the directory that you are currently in (the . is synonymous with 'here'-- you just 'pulled' in the file) EX: cp day.txt /home/web/dl, you just copied day.txt to a directory in dl -- you 'pushed' the file to a different directory. rm remove grep get record and print EX: grep 'almond' nuts.txt >>junk ; grabbed every line inside nuts.txt that contained the word 'almond' and put all those lines into a file called junk. cat concatenate (follow this command with all files you want to open) sort alphabetizes wc gives a word count uniq gets rid of adjacent identical lines (so use sort first) Examples: cat junk | sort > junk1 alphabetizes the lines of junk into a file called junk1 cat junk crap | sort | uniq >junk combines junk and crap, alphabetizes all lines, and removes identical lines, placing the output in a file called junk. Modifiers: -v do the reverse (EX: grep -v 'bus' file will give you all the lines in file that do NOT contain 'bus'. -i ignore case (EX: grep -i 'bus' file will give you all the ines in file that contain 'bus' or 'Bus' or 'BUS', etc. -c used with uniq, gives a count of the number of times a line occurred. (EX: cat file | sort | uniq -c >junk will give an alphabetized output in junk that lists beside each line the number of times that line occurred in file.
COMMANDS WITHIN A FILE
0 goes to beginning of line $ substitutes the word dollar for the word tab throughout the file 1G top of file (50G goes to line 50) G bottom of file w goes to next word i insert where cursor is a insert after cursor cw change word (5cw changes the next 5 words) dw delete word dd delete line d$ delete from cursor to end of line yy yanks line (12yy yanks 12 lines) p pastes the last thing you yy or dd into line under cursor (yy/p is like copy/paste;dd/p like cut/paste) u undo . repeats last command r replaces that letter /bus searches for the word 'bus'; pressing 'n' goes to the next 'bus' ?bus searches UP the file for the word 'bus' :w saves :q quits :r reads in a new file ma marks a line in file 'a goes back to that line :'a,'bw! junk puts everything between a and b into a file called junk :%s/tab/dollar/g substitutes the word 'dollar' for the word 'tab' throughout the file :e! refreshes file without saving :g/was/d deletes every line containing 'was' :!g/was/d deletes every line NOT containing 'was'
EXERCISES: 1. Create a directory within your users directory called 'play'. This is where you will practice unix/vi/html. 2. Using the Aliases, practice navigating around in terminals. use 'dir' and 'ls'. get familiar with where stuff is located. 3. In /home/web/dl/who/CV, work on your html skills by updating your CV (See Becka if you don't have a CV template there). 4. There is a directory within this directory called 'becka'. Copy the file 'list.txt' from there to your play area (push it) and follow the instructions inside. 5. Also in the becka directory is a file called 'leap_day.txt'. From your play directory, copy this file to your play area (pull it) and follow the instructions inside.