Posts

Showing posts from 2017

Permission and Ownership using awk

Image
Awk programming The easiest way to learn the awk command usage is to see them in action. In order to find the working directory we are in . Type pwd ( "print working directory" ) Then type ls ( listing)for listing to see what's in the current directory $ ls Permissions and Ownership List directories and files ls -al # shows something like this for each file/dir: drwxrwxrwx # d: directory # rwx: read write execute # first triplet: user permissions (u) # second triplet: group permissions (g) # third triplet: world permissions (o)     It shows like this when we type   $ls -al   drwxr-xr-x 2 prakash prakash 4096 Oct 27 03:56 Videos drwxr-xr-x 2 prakash prakash 4096 Nov 18 10:19 .vim -rw------- 1 prakash prakash 11158 Dec 16 18:54 .viminfo -rw------- 1 prakash prakash 124 Dec 16 18:11 .Xauthority -rw------- 1 prakash prakash 82 Dec 16 18:11 .xsession-errors Assign write and execute permission...

What is Linux Shell?

Image
  What is Linux Shell? In Linux and Unix, a shell refers to a program that is used to interpret the typed commands the user sends to the operating system.  The closest analogy in windows is  MS-DOS, Shell name is COMMAND.COM which is also used for same purpose, but it's not as powerful as our Linux Shells are! Computer understand the language of 0's and 1's called binary language. In early days of computing, instruction are provided using binary language, which is difficult for all of us, to read and write. So in OS there is special program called Shell. Shell accepts your instruction or commands in English (mostly) and if its a valid command, it is pass to kernel.   Shell is a user program or it's environment provided for user interaction. Shell is an command language interpreter that executes commands read from the standard input device (keyboard) or from a file. Shell is not part of system kernel, but uses the system kernel to execute pr...

AWK programming language

AWK is a programming language designed for text processing and typically used as a data extraction and reporting tool. It is a standard feature of most Unix-like operating system. When written in all lowercase letters, as awk , it refers to the Unix or Plan 9 program that runs scripts written in the AWK programming language. SOME AWK COMMANDS AND USE: to find all the lines with a string ‘foo’ awk ‘/foo/ {print}’ file to print line 1 to 2 awk ‘NR == 1, NR == 2 {print}’ file to print line 15000 to end of the file awk 'NR==15000, NR==$NR' test.csv to print 2nd and last columns awk '{print $2,$NF;}' employee.txt In the print statement ‘,’ is a concatenator. Printf >> Dash (‘-’) means left aligned awk -F ' ' '{printf "%-10s%-10s%-10s\n", $2,$4,$6}' Sprintf >> Replace the first field by its formatted representation and output the line. awk '{$1 = sprintf("%4d", $1); print}' infile > outfil...