sort - Sort-Merge Files $sort [ cmu ] [ ofile ] [ yk ] [ zn ] [ dfiMnr] [ btc ] [ +pos1 pos2 ]] [ files ] Description: The sort command sorts lines from files. Options:
tr - Translate Characters $tr [ cds ] [ string1 ] [ string2 ] Description: The tr command copies standard input to output and translates characters from string1 to characters in string2. Options:
Strings:
uniq - Report Duplicate Lines $uniq [ udc [ +n ] [ n ] ] [ file1 [ file2 ] ] Description: The uniq command removes duplicate adjacent lines from file1 and places the output in file2. Options:
wc - Count Characters, Lines and Words $wc [ clw ] [ files ] Description: The wc command counts the characters, lines, or words in the specified files. A total count for all files is kept. Options:
EXAMPLE COMMANDS# Execute multiple commands on one line % pwd ; ls tmp ; echo "Hello world" # Run the find command in the background % find . -name tmp.out -print & # Connect the output of who to grep % who | grep fred # Talk to fred if he is logged on % ( who | grep fred ) && talk fred # Send ls output to ls.out % ls > ls.out # Send find standard output and standard error to find.out % find / -atime +90 -print >& find.out # Append output of ls to ls.out; do not check if ls.out exists % ls >>! ls.out # Send invite.txt to dick, jane, and spot % mail dick jane spot < invite.txt # List file names that begin with z % ls z* # List two, three, and four character file names % ls {??, ???, ????} # List file names that begin with a, b, or c % ls [a-c]* # List the files in sam's home directory % ls ~sam # Create an alias for the ls lR command % alias lsl "ls -lR" # Reexecute last command % !! # Reexecute the last more command % !more # Reexecute the last command, changing adm to sys % ^sys^adm # Reexecute last find command, changing tmp to core % !find:*:s/tmp/core # Set NU to the number of users that are logged on % set NU=`who | wc -l` # Set TOTAL to the sum of 4 + 3 % @ TOTAL=4 + 3 # Set LBIN to /usr/lbin % set LBIN=/usr/lbin # Unset variable LBIN % unset LBIN # Add /usr/lbin to the path variable % set path=($path /usr/lbin) # Disable filename substitution % set noglob # Display $HOME set to /home/anatole % echo '$HOME set to' $HOME # Display the number of positional parameters % echo "There are $#argv positional parameters" # Display the value of positional parameter 2 % echo $argv[2] # Display the number of words in path % echo $#path # Bring background job 3 into the foreground % fg %3 # Stop the find job % stop %find # Display all information about current jobs % jobs -l # Terminate job 5 % kill %5 # Increment variable X % @ X=X++ # Set variable X to 20 modulo 5 % @ X=20 % 5 # Set diagnostic mode % csh -x # Run the dbscript in noexec mode % csh -n dbscript # Display the current directory stack % dirs # Put /usr/spool/uucppublic on the directory stack and cd to it % pushd /usr/spool/uucppublic # Check for new mail every 2 minutes % set mail=(120 ~/newmail) # Set prompt to the command number and current directory % set prompt=!`pwd` # Check if VAR is set to null % if ($?VAR) echo "VAR set ok" # Check if VAR is set to ABC % if ($VAR == "ABC" ) echo "VAR set to ABC" # Check if xfile is empty % if (-z xfile ) echo "xfile is empty" # Check if tmp is a directory % if ( -d tmp ) echo "tmp is a directory" # Check if file is readable and writable % if (-r file && -w file ) echo "file ok" # Set a trap to ignore interrupts % onintr - # Set the file size creation limit to 10 Mbytes % limit filesize 10m # Remove the limitation on the cputime resource % unlimit cputime # Read and execute the commands in .runlog % source .runlog # Disable core dumps % limit coredumpsize 0m # Display the last 10 commands % history -r 10 # Add group write permission to the file creation mask % umask 013 # Display the first and third fields from file % awk '{print $1, $3}' file # Display the first seven characters of each line in tfile % cut c17 tfile # Display the first and third fields from the /etc/passwd file % cut f1,3 d":" /etc/passwd # Display lines in names that begin with A, B, C, or Z % egrep '[AC,Z]*' names # Display lines from dict that contain four character words % egrep '....' dict # Display password entries for users with the Korn shell % grep ":/bin/ksh$' /etc/passwd # Display number of lines in ufile that contain unix; ignore case % grep c 'unix' ufile # Display the lengths of field 1 from file % nawk '{TMP=length($1); print $TMP}' file # Display the first ten lines of tfile % nawk '{for (i=1; i<10; i++) printf "%s\n", \ getline}' tfile # List the contents of the current directory in three columns % ls | paste d" " # Display file with all occurrences of The substituted with A % sed 's/The/A/g' file # Display your user name only % id | sed 's/).*//' | sed 's/.*(//' # Display file with lines that contain unix deleted % sed '/unix/d' file # Display the first 50 lines of file % sed 50q file # Sort the /etc/passwd file by group id % sort -t":" -n +3 -4 /etc/passwd # Translate lower case letters in file to upper case % cat file | tr a-z A-Z # Display adjacent duplicate lines in file % uniq d file # Display the numbers of characters and words in file % wc l file # Display the number of .c files in the current directory % ls *.c | wc -l
|