awk Begin and End
AWK has several built-in variables. They are set by AWK when the program is run. We have already seen the NR, $0, and RSTART variables. The program prints the number of arguments of the AWK program and the first two arguments. ARGC is the number of command-line arguments; in our…
awk Programming
The name awk comes from the initials of its designers: Alfred V. Aho, Peter J. Weinberger, and Brian W. Kernighan. The original version of awk was written in 1977 at AT&T Bell Laboratories. In 1985 a new version made the programming language more powerful, introducing user-defined functions, multiple input streams,…
Unix Variable $* and $# Difference
Script Run The explanation and the results for the four cases are below. In the first case, the parameters are regarded as one long quoted string: Case 2 (unquoted) – the string is broken into words by the for loop: Case 3 – it treats each element of $@ as…
Unix Comparison Operator
Comparison Operators String Comparison Description Str1 = Str2 Returns true if the strings are equal Str1 != Str2 Returns true if the strings are not equal -n Str1 Returns true if the string is not null -z Str1 Returns true if the string is null Numeric Comparison Description expr1 -eq…
grep Command
The grep Command The grep command searches a file or files for lines that have a certain pattern. Syntax Options Sr. No. Option & Description 1. -v (Prints all lines that do not match pattern.) 2. -n (Prints the matched line and its line number.) 3. -l (Prints only the…
Shell Case Statement
Syntax Example Case Day Wise Decision Output Case Transport Mode
Shell if-elif-else Statement
Syntax Example Taking input from the user Taking Input in Command Line $1 is the first argument. To run ./script 5
Shell If-Else Statement
Syntax Example Nested if-else
Shell If Statement
Syntax Example