For make to be able to perform the essential steps only, it requires the steps to be specified in a file, called the makefile. By default the make utility assumes the name of this file to be Makefile or makefile. Any other name can be used for the makefile by using the commandline option -f<makefilename>. The contents of the makefile essentially describes the dependencies of the various generated files upon other files. For example, a .o file depends on the corresponding .c file, the target program depends on the .o files, and so on. Thus when the utility is invoked it reads the dependencies and by looking at the time-stamps of the files, if it finds that if a file is older than any of its dependency files, then that file is generated again. For this purpose, along with each dependency description the series of commands that are to be executed to generate a file from the files that it depends on, are specified in the makefile. To make the creation of specifications easy, make allows several conventions to be used inside the makefile, such as use of macros, implicit rules, etc.
To use this utility for a program, one has to create a make file. Then in the
directory containing the makefile, give the command -
make
Books : Unix Utilities by Tare (Tata McGraw Hill), Sun Solaris Manual (Program Compilation and Linking)
Under RCS system, a library of the different files is maintained. Initially each file has to be entered in the library. The library is simply the collection of the files in an RCS's internal format. The collection can exist in the same directory, or a separate directory may be maintained. Afterwards, to make changes to any file it has to be fetched out from the library. Then after making the modifications, it may be redeposited in the library. For all these operations there are a set of commands and command line options. When a file is entered in the library for the first time, it is assigned a version number 1.1, and when revised versions of the file are redeposited in the library using the command for the purpose, the new versions are given version numbers 1.2, 1.3, and so on. Internally the system uses a format to store the multiple versions of a file in which only the last version is stored in the actual form. The filename used by the library to store a file is same as the actual filename given by the user, but with a suffix ,v. i.e., for file g1.c the RCS library will have a file g1.c,v in which all the versions of g1.c are stored. For the version previous to the last the differences between the two versions are appended to the file, and so on. To make modifications, a user can specify the particular version of a file that is to be fetched out from the library. RCS allows some symbolic name to be attached to a version of a file. Thus, if at a point of time
g1.c has versions 1.1, 1.2 and 1.3then one can associate the string, say simple to version 1.2 of g1.c, version 1.1 of g2.c, 1.3 of g3.h and 1.1 of g4.l. Similarly, the string fancy can be associated to version 1.2 of g1.c, version 1.2 of g2.c, 1.4 of g3.h and 1.1 of g4.l. Then to generate the simple version of game one can use RCS commands to automatically fetch the relevant files for simple. To generate the fancy version of game one can get the relevant versions of files for fancy. RCS also provides methods to control concurrent modifications to the same file by multiple users by not allowing one to fetch a file until it has not been redeposited after an earlier fetch. However, fetching for read-only purpose can be performed any number of time. While depositing or re-depositing a file to the RCS library, one is also required to provide a short description of the nature of modifications which is recorded in the library file.
g2.c has versions 1.1 and 1.2
g3.h has versions 1.1, 1.2. 1.3 and 1.4
g4.l has version 1.1
There are several operations possible through the RCS commands. Some commonly used commands are -
Read man pages for rcs, ci, co, rlog, rcsdiff
sed "s/TU/Tezpur University/" campus_news.txt
Books : Unix Utilities by Tare (Tata McGraw Hill), Programming in UNIX by Kernighan and Pike (Prentice Hall of India).
grep [sS]oftware *.txtSome other operations possible using grep are - finding lines that do not match the pattern (-v option), counting number of lines that matches the pattern (-c option), and so on.
awk [ options ] -f <program-file> [ -- ] <file> ...An AWK program consists of a sequence of pattern-action statements and optional function definitions.
awk [ options ] [ -- ] <program-text> <file> ...
pattern { action statements }Like in sed, the pattern specifies a condition for selecting lines from the input file, and the action statements are processing logic to be used in respect of the selected line. The pattern in case of awk provides more possibilities than its counterpart in sed. Similarly, since awk is a programming language in itself, hence the action statements in an awk program can be much more capable than the action specified in sed. The awk programming language supports features such as variables, composite data structures (arrays, records, etc.), conditional statements, loops, etc.
function name(parameter list) { statements }
Example :
Print and sort the login names of all users:Explanation : BEGIN is a special pattern and causes the corresponding action to be taken before input processing starts. In the above example, the action in the BEGIN block is to set the in-built variable FS (field-separator to be used in the lines of input) to ":", i.e., colon. In the following statement, there is no explicit pattern. This means this action is to be taken for all lines of input. Thus the overall effect is to consider the segments separated by colon in the input lines as separate fields and print the first field. But the output of the print is piped to the function "sort", so the fields will be printed in sorted order. Similarly, in the second example, the action of incrementing the variable nlines is executed for each line of input (since pattern is not specified). END is a special pattern which causes the corresponding action to be taken when all input has been processed. Hence, in the second example the variable nlines shall count the number of lines in the input and finally this value will be printed on the terminal. To count the number of lines containing the pattern "Tezpur" or "Guwahati" we can writeBEGIN { FS = ":" }Count lines in a file:{ print $1 | "sort" }{ nlines++ }END { print nlines }
/Tezpur/ || /Guwahati/ { nlines++ }
END { print nlines }
Books : Unix Utilities by Tare (Tata McGraw Hill), Programming in UNIX by Kernighan and Pike (Prentice Hall of India).