H I O X INDIA
LINUX Commands
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Templates 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)
Español Français 中文 Deutsch
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

LINUX / UNIX cmd
Introduction
Commands in A
Commands in B
Commands in C
Commands in D
Commands in E
Commands in F
Commands in G
Commands in H
Commands in I
Commands in J
Commands in K
Commands in L
Commands in M
Commands in N
Commands in P
Commands in R
Commands in S
Commands in T
Commands in U
Commands in W
Commands in Y
More about Linux
Feedback




awk Linux Commands


Topic

What is Linux awk Command?




Explanation

awk COMMAND:
     awk command is used to manipulate the text.This command checks each line of a file, looking for patterns that match those given on the command line.

SYNTAX:
  The Syntax is
     awk '{pattern + action}' {filenames}

OPTIONS:
     
-W version Display version information and exit.
-F Print help message and exit.



EXAMPLE:
     Lets create a file file1.txt and let it have the following data:
Data in file1.txt
14   15   16
15   15   11
5     56    6
5     25    1
  1. To print the second column data in file1.txt
    awk '{print $2}' file1.txt

    This command will manipulate and print second column of text file (file1.txt). The output will look like

    15
    15
    56
    25

  2. To multiply the column-1 and column-2 and redirect the output to file2.txt:
    awk '{print $1,$2,$1*$2}' file1.txt > file2.txt
    Command Explanation:
    $1 : Prints 1st column
    $2 : Prints 2ndcolumn
    $1*$2 : Prints Result of $1 x $2
    file1.txt :  input file
    > :  redirection symbol
    file2.txt :  output file

    The above command will redirect the output to file2.txt and it will look like,
    14    15    210
    15    15    225
    5      56    280
    5      25    125






        Find LINUX Commands... Hope you enjoy this tutorial. We welcome your Valuable feedbacks or suggestions on this LINUX / UNIX cmd reference. This is a copyright content.


privacy policy     license     sitemap
© 2004-2009 HIOX INDIA - hioxindia.com

Other Links