############################ #Contents of lesson 3: #Written by Jen Chen #Date: 04/17/04 #Copyrighted by Jen Chen ############################ #To count the number of records in the Orders.csv file, use this command: wc -l Orders.csv #To pull all records that contains the company "VINET" from the file Orders.csv #use: grep VINET Orders.csv #To see the fist 2 records from the file Orders.csv use the command "head": head -2 Orders.csv #To pull all records that contain the invoice number 10248, use grep: #Note that this will retrieve ALL records contain "10248", such as 102481, etc..#If you'd like to pull out just those records contain exactly the invoice 10248 #then put a space BEFORE or AFTER the invoice number. grep 10248 Orders.csv #Display all records with field 2 then compress the repeating records and count #only records with unique values in field 2. awk -F, '{print $2}' Orders.csv | sort -u #To print the field number for each record in the file Orders.csv. awk -F, '{print $NF}' Orders.csv #To create a shortcut for any Unix command, use "alias" as follow: #This alias is available ONLY for this logged in session. To make your aliases #permanent, then create a ".alias" file in your home directory. After you logged#out, log in again and these aliases will be available from now on. alias c clear #To create an alias to find all Cshell script from the current directory, do: alias find 'find . -name "*.csh" -print ' #To create an alias to find all Cshell script starting from a user's directory, #do as follow: (pay attention to the / and the period AFTER the $HOME variable. alias find 'find $HOME/. -name "*.csh" -print' #To create an alias for chmod 700 and accept the argument passed to your alias, #then add the \^! in your alias. The sign \!^ means to ACCEPT the command line #argument as argument in your alias. alias mod7 'chmod 700 \!^' #To find out who logged on to the server neptune, use finger as follow: finger @neptune #To turn off all messages that other users want to talk to you while you are #online use the "mesg" command with option n as follow: mesg -n #To extract the log in name of all users logged on to the current server without#any duplicate, combine the following Unix commands: who | awk '{print $1}' | sort -u #Same as above but this time we're interesting in displaying the contents of #record 3. Note that "NR" in awk stands for "number of records". who | awk '{print $1}' | sort -u | awk '{if(NR==3) print}' #Mail the contents of the file junkmesg.txt to user jchen13@calstatela.edu. mail username@calstatela.edu < junkmesg.txt #Append the last 30 Unix commands to the end of the file lesson3Sp04.txt. history +300 >> lesson3Sp04.txt #Replace all occurence of the symbol % with nothing in the Details.csv file: sed 's/\%//g' Details.csv