Skip to Content
Learning Linux Shell Scripting - Second Edition
book

Learning Linux Shell Scripting - Second Edition

by Ganesh Sanjiv Naik
May 2018
Beginner
332 pages
7h 28m
English
Packt Publishing
Content preview from Learning Linux Shell Scripting - Second Edition

Using variables in awk

We can simply declare a variable in the awk script, even without any initialization. Variables can be of type string, number, floating type, and so on. There is no type declaration required such as in C programming. awk will find out the type of variable by its right-hand side data type during initialization or its usage in the script.

Uninitialized variables will have the value 0 or strings will have a value null such as "", depending on how it is used inside scripts:

    name = "Ganesh"
  

The variable name is of the string type:

    j++
  

The variable j is a number. Variable j is initialized to zero and it is incremented by one:

    value = 50
  

The value variable is a number with an initial value of 50.

The technique to modify ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Linux Shell Scripting

Learning Linux Shell Scripting

Ganesh Sanjiv Naik
Linux Shell Scripting Cookbook - Third Edition

Linux Shell Scripting Cookbook - Third Edition

Clif Flynt, Sarath Lakshman, Shantanu Tushar

Publisher Resources

ISBN: 9781788993197Supplemental Content