Sponsored Content
Full Discussion: AWK for a beginner
Top Forums Shell Programming and Scripting AWK for a beginner Post 302703189 by omega3 on Wednesday 19th of September 2012 12:14:07 PM
Old 09-19-2012
AWK for a beginner

I am going to learn AWK for Pattern search (extracting strings ) related activities. I think that is what AWK is used for anyway.
What book/similair resource would you suggest for a beginner ?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Please help. I am a beginner.

Alrigt, I need to write a shell script where it counts the number of folders and files and dispays "My home directory has 'x' files and 'y' directories." So, I was thinking of doing this. set x = `ls | wc` so, if I have 8 files and folders in my home directory, x is not 8. now, I was... (1 Reply)
Discussion started by: Lykathea Aflame
1 Replies

2. Programming

Beginner C

Anyone know where I can get started in C++ programming in unix? Any good free tutorials or websites to start at? I am okay in unix scripting but have never done c programming of any sort... What are the main advantages of using C++ ? (2 Replies)
Discussion started by: frustrated1
2 Replies

3. UNIX for Dummies Questions & Answers

AWK help please - beginner

Hi, I'm in dire need of some help for AWK. I'm a college student and my statistics professor decided he'd teach AWK in the last two days of our class, even when it's not programming class and we don't even have computers in class to experiment. Anyway, I tried looking at AWK tutorials, but it... (4 Replies)
Discussion started by: COLLEGE
4 Replies

4. UNIX for Dummies Questions & Answers

Beginner Help

hi guys, i have a DEl xps laptop cor 2 duo 2.2 i have vista installed on it i want to install a dual Boot UNIX on it.. can some one guide me ...cause i m tottaly new to UNIX i want to install unix on that laptop along with Vista.... thx any help would be deeply appreciated (sorry if i... (5 Replies)
Discussion started by: Farhan082
5 Replies

5. Shell Programming and Scripting

Beginner Help

I need to write a script to test a nsort c program. I have written 8 .txt files with different cases. Also 8 .txt files with expected outcome. The shell I have written always "test pass" for the first case but always "fail" for the rest... Here is a portion of my code (as I still don't know how to... (5 Replies)
Discussion started by: thibodeau
5 Replies

6. UNIX for Dummies Questions & Answers

Beginner - What Should I Do First?

Hi people.... I have just started to learn unix.I want to know which version of Unix to install plus how to install it.I need to practise and make myself aware of how unix works.My thread is from an educational point of view.Also please feel free to give your suggestions as I am... (3 Replies)
Discussion started by: amit.kanade1983
3 Replies

7. Shell Programming and Scripting

Beginner looking for help

Hello, I am trying to write a script that reads names from a file called input, removes names if they have the same letter next to each other and prints the others. e.g. Colin & John would be printed Garry & Lynn would be removed My thinking is that I read in each name and... (3 Replies)
Discussion started by: colinireland
3 Replies

8. Shell Programming and Scripting

""Help Me!""Beginner awk learning issue

Hi All, I have just now started learning awk from the source - Awk - A Tutorial and Introduction - by Bruce Barnett and the bad part is that I am stuck on the very first example for running the awk script. The script is as - #!/bin/sh # Linux users have to change $8 to $9 awk ' BEGIN ... (6 Replies)
Discussion started by: csrohit
6 Replies

9. UNIX for Dummies Questions & Answers

awk Help - Beginner

Hi, I think I need to use AWK - however I have no experience of it. Can someone help please? I have a file like this but with many more records - it is fixed width THIS15021X 799999 XX 00000099999 00008888888 XX 15022013 THISQ15021X 999999 XX 00000099999... (7 Replies)
Discussion started by: mcclunyboy
7 Replies

10. Red Hat

Help me please i am beginner

i have windows 8 host on Dell Laptop vmware 9 redhat 7.2 iso downloaded through redhat official site after installation on vm it only boots into text dont show graphics Please guide:( (1 Reply)
Discussion started by: hananabbas
1 Replies
regexp(3erl)						     Erlang Module Definition						      regexp(3erl)

NAME
regexp - Regular Expression Functions for Strings DESCRIPTION
Note: This module has been obsoleted by the re module and will be removed in a future release. This module contains functions for regular expression matching and substitution. EXPORTS
match(String, RegExp) -> MatchRes Types String = RegExp = string() MatchRes = {match,Start,Length} | nomatch | {error,errordesc()} Start = Length = integer() Finds the first, longest match of the regular expression RegExp in String . This function searches for the longest possible match and returns the first one found if there are several expressions of the same length. It returns as follows: {match,Start,Length} : if the match succeeded. Start is the starting position of the match, and Length is the length of the matching string. nomatch : if there were no matching characters. {error,Error} : if there was an error in RegExp . first_match(String, RegExp) -> MatchRes Types String = RegExp = string() MatchRes = {match,Start,Length} | nomatch | {error,errordesc()} Start = Length = integer() Finds the first match of the regular expression RegExp in String . This call is usually faster than match and it is also a useful way to ascertain that a match exists. It returns as follows: {match,Start,Length} : if the match succeeded. Start is the starting position of the match and Length is the length of the matching string. nomatch : if there were no matching characters. {error,Error} : if there was an error in RegExp . matches(String, RegExp) -> MatchRes Types String = RegExp = string() MatchRes = {match, Matches} | {error, errordesc()} Matches = list() Finds all non-overlapping matches of the expression RegExp in String . It returns as follows: {match, Matches} : if the regular expression was correct. The list will be empty if there was no match. Each element in the list looks like {Start, Length} , where Start is the starting position of the match, and Length is the length of the matching string. {error,Error} : if there was an error in RegExp . sub(String, RegExp, New) -> SubRes Types String = RegExp = New = string() SubRes = {ok,NewString,RepCount} | {error,errordesc()} RepCount = integer() Substitutes the first occurrence of a substring matching RegExp in String with the string New . A & in the string New is replaced by the matched substring of String . & puts a literal & into the replacement string. It returns as follows: {ok,NewString,RepCount} : if RegExp is correct. RepCount is the number of replacements which have been made (this will be either 0 or 1). {error, Error} : if there is an error in RegExp . gsub(String, RegExp, New) -> SubRes Types String = RegExp = New = string() SubRes = {ok,NewString,RepCount} | {error,errordesc()} RepCount = integer() The same as sub , except that all non-overlapping occurrences of a substring matching RegExp in String are replaced by the string New . It returns: {ok,NewString,RepCount} : if RegExp is correct. RepCount is the number of replacements which have been made. {error, Error} : if there is an error in RegExp . split(String, RegExp) -> SplitRes Types String = RegExp = string() SubRes = {ok,FieldList} | {error,errordesc()} Fieldlist = [string()] String is split into fields (sub-strings) by the regular expression RegExp . If the separator expression is " " (a single space), then the fields are separated by blanks and/or tabs and leading and trailing blanks and tabs are discarded. For all other values of the separator, leading and trailing blanks and tabs are not discarded. It returns: {ok, FieldList} : to indicate that the string has been split up into the fields of FieldList . {error, Error} : if there is an error in RegExp . sh_to_awk(ShRegExp) -> AwkRegExp Types ShRegExp AwkRegExp = string() SubRes = {ok,NewString,RepCount} | {error,errordesc()} RepCount = integer() Converts the sh type regular expression ShRegExp into a full AWK regular expression. Returns the converted regular expression string. sh expressions are used in the shell for matching file names and have the following special characters: * : matches any string including the null string. ? : matches any single character. [...] : matches any of the enclosed characters. Character ranges are specified by a pair of characters separated by a - . If the first character after [ is a ! , then any character not enclosed is matched. It may sometimes be more practical to use sh type expansions as they are simpler and easier to use, even though they are not as pow- erful. parse(RegExp) -> ParseRes Types RegExp = string() ParseRes = {ok,RE} | {error,errordesc()} Parses the regular expression RegExp and builds the internal representation used in the other regular expression functions. Such representations can be used in all of the other functions instead of a regular expression string. This is more efficient when the same regular expression is used in many strings. It returns: {ok, RE} if RegExp is correct and RE is the internal representation. : {error, Error} if there is an error in RegExpString . : format_error(ErrorDescriptor) -> Chars Types ErrorDescriptor = errordesc() Chars = [char() | Chars] Returns a string which describes the error ErrorDescriptor returned when there is an error in a regular expression. REGULAR EXPRESSIONS
The regular expressions allowed here is a subset of the set found in egrep and in the AWK programming language, as defined in the book, The AWK Programming Language, by A. V. Aho, B. W. Kernighan, P. J. Weinberger . They are composed of the following characters: c : matches the non-metacharacter c . c : matches the escape sequence or literal character c . . : matches any character. ^ : matches the beginning of a string. $ : matches the end of a string. [abc...] : character class, which matches any of the characters abc... Character ranges are specified by a pair of characters separated by a - . [^abc...] : negated character class, which matches any character except abc... . r1 | r2 : alternation. It matches either r1 or r2 . r1r2 : concatenation. It matches r1 and then r2 . r+ : matches one or more r s. r* : matches zero or more r s. r? : matches zero or one r s. (r) : grouping. It matches r . The escape sequences allowed are the same as for Erlang strings:  : backspace f : form feed : newline (line feed) : carriage return : tab e : escape v : vertical tab s : space d : delete ddd : the octal value ddd xhh : The hexadecimal value hh . x{h...} : The hexadecimal value h... . c : any other character literally, for example \ for backslash, " for ") To make these functions easier to use, in combination with the function io:get_line which terminates the input line with a new line, the $ characters also matches a string ending with "... " . The following examples define Erlang data types: Atoms [a-z][0-9a-zA-Z_]* Variables [A-Z_][0-9a-zA-Z_]* Floats (+|-)?[0-9]+.[0-9]+((E|e)(+|-)?[0-9]+)? Regular expressions are written as Erlang strings when used with the functions in this module. This means that any or " characters in a regular expression string must be written with as they are also escape characters for the string. For example, the regular expression string for Erlang floats is: "(\+|-)?[0-9]+\.[0-9]+((E|e)(\+|-)?[0-9]+)?" . It is not really necessary to have the escape sequences as part of the regular expression syntax as they can always be generated directly in the string. They are included for completeness and can they can also be useful when generating regular expressions, or when they are entered other than with Erlang strings. Ericsson AB stdlib 1.17.3 regexp(3erl)
All times are GMT -4. The time now is 07:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy