PS1="..." change prompt PS1="UNIX:" .profile (prefs) export PS1 cat -v file view non-printing ASCII letters: ls -b show non-printing chars umask 077 all me begin of .profile chown liz file change owner find . -name it -print -u liz file * in page or pg move +3 or -5 d=1/2 screen /searchtext/ ?backwards? head tail file tail -3 -f file display last 3 lines -waits- display any new lines pr file | lp prints header info i.e. date file page pr -t "customized header" file | lp pr -d (doublespace) -n (add line #'s) -3 (3 cols) fmt -w 16 file formats 16 letters per line date; ls run 2 cmds same cmd line with ; ? (like *) match single char (*=multi string) [2-4] letters 2-4 env mail `cat names` ` == substitution csh: uses .cshrc and .login (.cshrc every time run the shell) setenv SHELL /usr/bin/csh set ignoreeof prevent ctrl-D logging me off !vi repeats last cmd vi on history or !# or !-2 go back 2 cmds (csh: [ksh=r]!! repeat last cmd mv !vi:$ newfile !:s/old/new or %^old^new set -o vi (ksh) cmd line --> vi editor // search again or 'n' ? backwards or 'N' yy=Y "ayy yanks line into buffer a "aP put "Ayy appends line to buffer a :r !date replace line with date output vi -audoindent (ai) [noai] -ignorecase (ic) [noic] -number (nu) [nonu] .exrc per directory and .login directory set ai noic nonu liz/.exrc need set exrc .profile: EXINIT="set ai nonu" export EXINIT .cshrc EXINIT="set ai nonu" export EXINIT grep -v lines do not match -l not print line just filename cut -f1,3-4 fn prints fields 1,3,4 -c char # i.e. column paste states abbr => Alabama Al / Alaska AK join matches a key field to paste sort source .cshrc recompile to use ^D as typing cmd to see desired directory on cmd line :.,$s/CNTRL-V M//g vi: delete ^M globally ^L in file: tells lp print on new page \ command line: can continue typing on next line (or in shell script) !$ replace with previous command argument name G goto last line H goto top of screen L goto bottom of screen h-j-k-l cursor movements ^D ^U scroll half screen down / up ^f ^B scroll full screen forward / back :.,+10s/old/new/g from here +10 lines change old to new g=globally :0,$s/old/new/g from here line 0 (top) to $=bottom change old to new g=globally :10,20s/$/new/ from lines 10 to 20 add to end of line 'new' (use ^ to insert beginning of line) :.,$d from here to end delete :1,.d from top to here delete tail -100f error.log view last 100 lines and continual tail view on file during processing lp -y landscape print landscape wise /Header..buf search where '..' = anything cntrl-G display filename line # of total; --%-- if Modified xterm -display owl:0 on remote login display on my local machine owl:0 #c vi: change following # characters with new entry mkdir cd ; tar cf - . | ( cd ; tar xf - ) copies dir preserving permissions, person, dates, etc ds -u * disk usage, after above cmd see if approx same such that no anomolies (big word!) CDROM -eject A: mount /pc3 lp -T PS cat /home/liz/example.au | rsh mouse hdsplay plays sound on bob's machine mouse via hds enscript -2rGdflute print 2 columns, landscape (r), smaller font, destination flute printer :.,$s///g delete from tag :.,$s/^$\n// delete all blank lines :v/./d or :g/^$/d delete all blank lines :g/^[]*$/d delete all lines with only whitespace :v/./.,/./-1join replace multiple blank lines with just one blank line cd - change dir to previous one (so easy to swap between two dirs) cp -p x x2 -p keeps the date and time of source file for new copied file :se wm=8 will do on word margins. :1,$!fmt fmt does a nice job of cleaning up the lines. :.,$s/^ .*$\n// deletes all lines starting with a tab :.!date inserts the command line command output into the document at . xp del char under cursor and put after (swaps location of two chars) :g/.*/m0 reverse order of lines in file (m0=move line to line 0) yw yanks the word into buffer, p to put nyw yanks n words to buffer, p to put ~ over a char swaps the case from lower to upper or vice vs. awk '{print $1 " " $2 ".eps " $2 ".jpg"}' statconvert.sh > convert2jpg.sh copy column 2 to do this in vi, cat faq2 | cut -f1 -d' ' | sort | uniq -c | sort -r extracts first field or col, count and sort in a list of most occurances!!! # number each line of a file (simple left alignment). Using a tab (see # note on '\t' at end of file) instead of space will preserve margins. sed = filename | sed 'N;s/\n/\t/' # sed command to remove all punctuation characters sed 's/[,.?-]//g' cat *xt | sed "s/[-,.:<>=_{}?;|\!@\#\$\%*&+)(/\"\'\`]//g" | tr "[" " " | tr "]" " " | tr " " "\012" | tr "\011" "\012" | grep -v "^$" tail +63 filename | head -n1 where 63 is the line number to start, and 1 is how many lines to print ******************************* #!/usr/local/bin/ksh # by Stew Crawford-Hines - finds large files in any directory #find only files and get `ls -l' style data for them find . -type f -size +50 -ls | sed 's/^ *//' | #some have leading blanks -- strip them sort +6rn -7 | #sort by size tr -s ' ' ' ' | #squeeze multiple blanks into a tab cut -f7- #and cut out only the interesting fields ******************************* awk '( NR > 1 ) { print}' skip first line in file sed G file # Double space a file This makes the change to all occurrences of the pattern on the line. We can also place multiple instructions on the same line by using the –e option or using a semicolon (;) to separate the commands: $sed –e ‘s/100-/(100) /g’-e ‘s/101-/(101) /g’ phonelist $sed ‘s/100-/(100) /g’; ‘s/101-/(101) /g’ phonelist RegEx perl : [0-9]{3}-[0-9]{3}-[0-9]{4} RegEx php : [0-9]{3}-[0-9]{3}-[0-9]{4} RegEx postgres: [0-9]{3}-[0-9]{3}-[0-9]{4} RegEx python : [0-9]{3}-[0-9]{3}-[0-9]{4} RegEx sed : [0-9]\{3\}-[0-9]\{3\}-[0-9]\{4\} RegEx vim : [0-9]\{3}-[0-9]\{3}-[0-9]\{4} sed 's/^[ ]*//' remove leading spaces and tabs (add tab) compress 1 or more adjacent white spaces # s/[ ][ ]*/ /g set -- $line splits a variable aka line s.t. $1 is first token, $2 = second, cat $file | while read line reads each line in file line-by-line echo into a while read line... while read splits into a pipe so no access to script vars!!! lynx -dump *.html > $*.txt convert html to text, formatted like a paper (links -> references) WOO HOO!!!!!! get external variable into an awk statement!!!! export THRESH=6 awk ' ($2 > ENVIRON["THRESH"]) {print $2 " / " ENVIRON["THRESH"] " " $1}' $filenameIn # Put all words on lines by themselves. This converts all non-alphanumeric characters to newlines, then squeezes each string of repeated newlines into a single newline: tr -cs 'a-zA-Z0-9' '[\n*]' set -vx print each shell script cmd before executing set -e terminate script on first error cd - return to dir you were previously in