Home > Programming > Shell Programming



Advanced Topics in Shell Scripting Awk sed and grep.

Sort Desciption:

shell scripts do but less than that of a full programming language. TCL/TK TCL (pronounced Tickle!) is a more complex scripting language with far more ...



Content Inside:

Advanced Topics in Shell Scripting Awk sed and grep.Page 1Advanced Topics in Shell Scriptingby: Colin Sauze 07/28/2005http://www.securitydocs.com/libr ary/3489This article focuses on more advanced topics in shell scripting including a number of common utilities which can help you writemore versatile shell scripts.Awk sed and grep.You will often here these 3 tools talked about together. They are very useful for getting the output format of other programsinto a format which is useful to you in a shell script. Awk is mainly used for splitting up text based around what is called a fieldseparator (e.g. In a:B:c:d : is the field separator). Sed is used to alter the contents of a file or the output of a program in someway its often used to remove unwanted output or to alter files. Grep is used to match patterns within its input or a file. Sed andgrep both use a pattern matching language called regular expressions more will be explained about these later on andadditional references are available at the end of this tutorial.AwkAwk's main use is to split up text into separate fields allowing you to get hold of just part of the input to a script or the output ofanother program. Awk is actually capable of doing far more than this whole books exist about awk and this tutorial cannothope to fully explain it so will focus on field separation as its main use.By default awk will split its input using spaces to separate each field the main way awk gets its input is from a pipe fromanother program although it can read files itself. As an example here we are going to use some text from the output of theifconfig program in Linux which displays information about the network cards in a machine. We're just going to use the first lineof the output here which is eth0 Link encap:Ethernet HWaddr 00:50:BE:DD:76:CD.Now suppose we want to find out what the network interface's name is (its eth0) in order to compare it to a variable we alreadyhave in our shell script (perhaps something we got from a ...

Source: www.securitydocs.com


add to Google Reader add to Google Bookmark add to bloglines add to newsgator add to FURL add to digg add to webnews add to Netscape add to Yahoo MyWeb add to spurl.net add to diigo Bookmark newsvine Bookmark del.icio.us Bookmark @ SIMPIFY Bookmark MISTER WONG Bookmark Linkarena Bookmark icio.de Bookmark oneview Bookmark folkd.com Bookmark yigg.de Bookmark reddit Bookmark StumbleUpon Bookmark Slashdot Bookmark blinklist Bookmark technorati add to blogmarks add to blinkbits add to ma.gnolia add to smarking.com add to netvouz add to co.mments add to Connotea add to de.lirio.us

 

Related Files

basic shell programming

Filed under: Programming and Shell Programming
bash derives much of its programming functionality from shell variables. Weve ... builtin variables that are vital to shell programming. ...

Unix Shell Scripts

Filed under: Programming and Shell Programming
that file is called shell script language. Like other programming languages it has variables and flow control. statements (e.g. ifthenelse while for ...

UNIX Shell Programming

Filed under: Programming and Shell Programming
Page 1 of 1 ITC_UNIXsp ExecuTrain Course Outline UNIX Shell Programming IT0001 3 Days Description Students learn to read, write, and debug shell scripts, thus increasing ...

Automated testing using Shell Scripting

Filed under: Programming and Shell Programming
Advanced Bash scripting guide from The Linux Documentation Project (TLDP). Unix Shell Programming by Yashavant Kanetkar BPB Publication. ...

Shell Programming

Filed under: Programming and Shell Programming
This training in Shell Programming is designed for. administrator to create and debug shell scripts so as to. automate routine tasks. ...