Easysurf | Home | Site Map |
---|
E-mail ThisPage To A Friend |
---|
Copy each file and then paste it in a text editor. Save the file using the given filename. To copy: Click the "Highlight" button. This will highlight the text. Then from the Edit menu choose Copy. To paste: open a text editor, then from the Edit menu choose paste. command shell prompt =% command line prompt =% command Bash shell prompt =$ |
|
How to start UNIX on Macintosh OS X | |
filename: a1pg to save click "Highlight" copy % pico a1pg paste to run % tcsh a1pg | |
remove a file named adf2g % rm -i adf2g remove adf2g? y | |
man - display the on-line manual pages % man ls | |
filename: uf8 to run % tcsh uf8 | |
filename: uf8a to run % tcsh uf8a | |
filename: uflsa to run % tcsh uflsa list all files including hidden ones You can hide files by giving them a name that starts with a dot (.) | |
filename: .uf31 to run % tcsh .uf31 | |
filename: uflsf to run % tcsh uflsf directories/ | |
filename: uflsr | |
filename: uflss | |
filename: uf13 More is a filter which allows examination of a continuous text one screenful at a time on a soft-copy terminal. It normally pauses after each screenful, printing the current file name at the bottom of the screen or --More-- if input is from a pipe. If the user then types a carriage return, one more line is displayed. If the user hits a space, another screenful is displayed. | |
View files with more % more filename spacebar to see next screen b to see last screen enter or return to see the next line q to to go back to go back to shell prompt To view file contents % open filename % more filename % cat filename | |
filename: uf12 | |
filename: uf15 % ls > uf15 redirect output to file which is created % ls -l >> uf15a append output to an existing file or will create file % man ls >> uf15b append copy of a manual page to a file | |
Logging out % logout % exit [ctrl] [d] | |
SHELLS filename: uf44 to run % tcsh uf44 | |
filename: uf45 | |
BASH Apple did not include the Bash Shell in Darwin (OS X v10.1) Apple did include the Bash Shell in Jaguar (OS X v10.2) You can download the Bash Shell at Bash for OSX | |
% man ps % ps -aux % ps % csh % ps % sh % ps % zsh % ps % exit % ps % exit % ps % exit % bash $ ps $ exit UNIX Environment % set % setenv % man top % top | |
% cal % cal 2002 % cal 6 2002 % cal -j % cal -y % man cal | |
filename: uf179 echo to run % sh uf179 | |
filename: tm3 to run % tcsh tm3 | |
filename: uf185 ` (grave, backquote) shares the ~ (tilde) key to run % tcsh uf185 | |
cp - copy files mkdir - make directory mv - move files % mv oldname newmame - rename a file rm - remove file rmdir - remove directory which - locate a program file including aliases and paths (csh(1)) only) | |
SORT filename: address.book to save copy and paste % pico address.book | |
% cat address.book % man sort Sort by field 1 - Print records sorted by field 1 % sort address.book Sort by field 1 - Print records sorted by field 1 % sort -t, +0 address.book Sort by field 2 - Print records sorted by field 2 % sort -t, +1 address.book Sort by field 3 - Print records sorted by field 3 - leftmost digit % sort -t, +2 address.book Sort by field 3 - Print records sorted by field 3 - numerically % sort -nt, +2 address.book % sort address.book > sorted.address.book1 % cat sorted.address.book1 % sort -t, +1 address.book > sorted.address.book2 % cat sorted.address.book2 % sort -nt, +2 address.book > sorted.address.book3 % cat sorted.address.book3 Sort by field 1 - Print records sorted by field 1 - no duplicate records % sort address.book | uniq % sort address.book | uniq > sorted.address.book4 % cat sorted.address.book4 | |
filename: names.book to save copy and paste % pico names.book | |
% cat names.book Sort by field 1 - Print records sorted by field 1 % sort names.book % sort +1 names.book % sort +2 names.book % sort -n +3 names.book % sort names.book > sorted.names.book1 % cat sorted.names.book1 % sort +1 names.book > sorted.names.book2 % cat sorted.names.book2 % sort -n +3 names.book > sorted.names.book3 % cat sorted.names.book3 % sort names.book | uniq % sort names.book | uniq > sorted.names.book4 % cat sorted.names.book4 | |
% man wc % wc address.book % wc -c address.book -c The number of bytes in the file % wc -l address.book -l The number of lines in the file % wc -m address.book -m The number of characters in the file % wc -w address.book -w The number of words in the file | |
% man head % head address.book % head -2 address.book | |
% man tail % tail address.book % tail -3 address.book | |
% man grep Search for "Jim", Print only records that match search pattern % grep Jim address.book Search for "jim", Print only records that match search pattern - case-sensitive % grep jim address.book Search for "jim", Print only records that match search pattern - not case-sensitive % grep -i jim address.book Search for "Patti", Print only records that match search pattern % grep Patti address.book Search for "Patti", count number of records that match search pattern % grep -c Patti address.book Search for "Patti", Print only records that do not match search pattern % grep -v Patti address.book Search for "ra", Print only records that match search pattern % grep -e ra address.book | |
filename: blue1 to save copy and paste % pico blue1 | |
% man sed Change the word blue to green % sed s/blue/green/g blue1 % sed 's/blue/green/g' blue1 % sed 's/blue/green/g' blue1 > blue2 % cat blue2 | |
filename: st2 to save copy and paste % pico st2 | |
filename: addrs5.book to save copy and paste % pico addrs5.book | |
Change State abbreviation to State Name % sed -f st2 addrs5.book | |
filename: st5 to save copy and paste % pico st5 | |
filename: addrs4.book to save copy and paste % pico addrs4.book | |
Change State Name or STATE NAME TO State Abbreviation % sed -f st5 addrs4.book | |
filename: daysed to save copy and paste % pico daysed | |
filename: st6 to save copy and paste % pico st6 | |
Correct case Day name - match search pattern - make sed case insensitive % sed -f st6 daysed | |
filename: addrs1.book to save copy and paste % pico addrs1.book | |
% man awk Error - no file is given - ctrl + D to stop - return to command line % % awk '{ print $1 }' Print LAST name % easysurf% awk '{ print $1 }' addrs1.book Print LAST, FIRST name % easysurf% awk '{ print $1 ", " $2 }' addrs1.book Print the whole file, all fields % awk '{ print $1 " " $2 " " $3 " " $4 " " $5 " " $6 " " $7 " " $8 " " $9 " " $10 " " $11 " " $12 " " $13 }' addrs1.book Print Name: Sex: Date of Birth: and Address: % awk '{ print "Name: " $1 ", " $2 " Sex " $3 " Date of Birth " $5 "/" $6 "/" $4 }' addrs1.book | |
filename: addrs2.book to save copy and paste % pico addrs2.book | |
Print LAST name - field 1 % awk -F, '{ print $1 }' addrs2.book Print Name: Sex: Date of Birth: and Address: % awk -F, '{ print "Name: " $1 ", " $2 " Sex " $3 " Date of Birth: " $5 "/" $6 "/" $4 " Address: " $7 }' addrs2.book Search for "WIL", Print only records that match search pattern % awk -F, /WIL/'{ print "Name: " $1 ", " $2 " Sex " $3 " Date of Birth: " $5 "/" $6 "/" $4 " Address: " $7 }' addrs2.book Print the whole file, all fields % awk -F, '{ print $0 }' addrs2.book Print FIRST and LAST name % awk -F, '{ print $2 " " $1 }' addrs2.book Print LAST name and the number of letters in the LAST name % awk -F, '{ print $1 " - " length($1) " letters" }' addrs2.book Print each record without showing field 2 (FIRST name) % awk -F, '{ $2 =""; print }' addrs2.book Print Initial for FIRST name and all of LAST name % awk -F, '{ print substr($2,1,1) ". " $1 }' addrs2.book Print FIRST and LAST name using substr % awk -F, '{ print substr($2,1,length($2)) " " $1 }' addrs2.book Change FIRST and LAST name to First Last name - Initial Capitals % awk -F, '{ print substr($2,1,1) tolower(substr($2,2,length($2))) " " substr($1,1,1) tolower(substr($1,2,length($1))) }' addrs2.book Print FIRST and LAST name and change 5551234 to 555-1234 % awk -F, '{ print $2 " " $1 " " substr($11,1,3) "-" substr($11,4,4) }' addrs2.book Print FIRST and LAST name and Male if field 3 = M or Female if field 3 = F % awk -F, ' $3=="F" { print $2 " " $1 ", Female" } $3=="M" { print $2 " " $1 ", Male" }' addrs2.book | |
filename: addrs3.book to save copy and paste % pico addrs3.book | |
First Last name - Initial Capitals % awk '{ print toupper(substr($2,1,1)) tolower(substr($2,2,length($2))) " " toupper(substr($1,1,1)) tolower(substr($1,2,length($1))) }' addrs1.book % awk -F, '{ print toupper(substr($2,1,1)) tolower(substr($2,2,length($2))) " " toupper(substr($1,1,1)) tolower(substr($1,2,length($1))) }' addrs2.book % awk -F, '{ print toupper(substr($2,1,1)) tolower(substr($2,2,length($2))) " " toupper(substr($1,1,1)) tolower(substr($1,2,length($1))) }' addrs3.book | |
filename: bylname to save copy and paste % pico bylname | |
filename: bylname Sort by last name - Initial Capitals - address to run % sh bylname | |
filename: bylname2 to save copy and paste % pico bylname2 | |
filename: bylname2 Sort by last name in reverse order - Initial Capitals - 718-555-5754 to run % sh bylname2 | |
filename: byMonth to save copy and paste % pico byMonth | |
filename: byMonth Print names sorted by birth month # to run % sh byMonth | |
filename: for1 to save copy and paste % pico for1 | |
filename: for1 Print an array of months with a while loop to run % sh for1 | |
filename: for2 to save copy and paste % pico for2 | |
filename: for2 Print an array of months (number and name) with a while loop - tab and all members of the array to run % sh for2 | |
Escape Codes while and until loops#!/bin/sh # escape code -le less than or equal to i=1 while [ $i -le 12 ]; do print "\t" $i let i=i+1 done | |
filename: read1 to save copy and paste % pico read1 | |
filename: read1 Enter a number to print a month's name - if elif else fi to run % sh read1 | |
filename: read2 to save copy and paste % pico read2 | |
filename: read2 Enter a number to print a month's name - if elif else fi - test for correct input to run % sh read2 |
Last Updated: Saturday, October 6, 2007 |