[Solved] awk oddity


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [Solved] awk oddity
# 8  
Old 02-17-2014
Quote:
Originally Posted by djzah
Seriously just trying to learn and can't find any good beginner doco/books
I suggest "sed & awk" by Dale Dougherty, issued by O'Reilly and Associates. It is simply the best book on the subject i ever read.

Quote:
Originally Posted by djzah
I had to include all in the same line.
No, you don't. You can write multiline awk programs as part of the normal shell code as long as you enclose it in single quotes. Note the single quotes at the beginning and the end of the awk-program:

Code:
some_command |\
awk '{
        /^#/ {
                  next
             }

        /^\/\// {
                  next
             }
     }' /path/to/file |\
other_command

I hope this helps.

bakunin

Last edited by bakunin; 02-17-2014 at 10:02 AM..
# 9  
Old 02-17-2014
Hi.
Quote:
Originally Posted by djzah
.... Seriously just trying to learn and can't find any good beginner doco/books
A Google search for awk tutorial beginner OR novice produces about 70K hits. The first 2 looked good to me; I wrote and delivered a begiinning awk sub-course as part of a basic *nix series.

I agree with bakunin about the sed & awk book. See also:
Code:
Title: UNIX(R) Shells by Example 
Subtitle: ... guide to the C, Bourne, and Korn Shells plus Awk, Sed, and Grep
Author: Ellie Quigley
Edition: 4th
Date: 2004
Publisher: Prentice-Hall
ISBN: 013147572X
Pages: 1200
Categories: sh, csh, ksh, grep, sed, awk, scripting, shell, programming
Comments: 4.5 stars, 45 reviews Amazon (2007.07)
Comments: ( I have 2nd Ed, 1997 )
Comments: ( 4th edition includes bash and tcsh chapters )

and The AWK Programming Language: Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger: 9780201079814: Amazon.com: Books and Effective awk Programming (3rd Edition): Arnold Robbins: 9780596000707: Amazon.com: Books

Robbins is Mr GNU AWK (gawk).

Best wishes ... cheers, drl
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

System call oddity

Hi all, I'm trying to use bash to create a basic parser for some text, because basic grep/sed/awk have all my needs covered. So, I'm creating the chain of grep/sed I need and trying the execute that on the data I gather. The problem is, it's not working as it does when hardcoded. e.g. ... (3 Replies)
Discussion started by: beomagi
3 Replies

2. Solaris

Sort Oddity

All, I'm baffled by some sort behavior on SunOS 5.10 and looking for guidance. Running the command: sort -t'|' -k5,5 -k7,7 -k1,1 -k2,2 -k3,3 -k6,6 -k8,8 test Against the file "test": thirdA||||first||second|Data thirdB||||first||second| thirdC||||first||second|Data... (11 Replies)
Discussion started by: effigy
11 Replies

3. Programming

Java double subtraction oddity (not the usual rounding discrepancy)

I've been going through a java tutorial, and ran across some strangeness in this small example... class SqrRoot { public static void main(String args) { double num,sroot,rerr,resquare; for(num = 1.0; num < 100.0; num++) { sroot = Math.sqrt(num); ... (1 Reply)
Discussion started by: Trones
1 Replies

4. BSD

Cron Oddity

Our webserver is running FreeBSD, for the last few days we have been having an issue with our cronjobs/mysql server. Specifically we have jobs that execute php scripts to do various things to the website. When running these php scripts manually, via external browser, or lynx on the server, they... (8 Replies)
Discussion started by: mrfr0g
8 Replies

5. UNIX for Dummies Questions & Answers

TR squeeze oddity

I discovered that where 'tr -s' works as expected on grepped input, it appears to completely fail on dig results. I am not sure if this is because of some sort of non posix compliancy, or what. Here is what I did: The command below works as expected, squeezing all repeated spaces to a single... (3 Replies)
Discussion started by: bdmeyersc
3 Replies

6. AIX

AIX SAN configuration problems/oddity

Hi, I have a strange problem. we're trying to connect an IBM pseries, to a Brocade switch, for SAN acess, using a badged emulex card, (IBM FC6239) WE can configure the device to see the fabric. The only problem we have is that the Brocade sees the HBA as storage, and not as a HBA. We've zoned... (1 Reply)
Discussion started by: praxis22
1 Replies

7. UNIX for Dummies Questions & Answers

VSFTP oddity

I am using smartFTP client on my windows machine to connect to a linux box of mine (different location) to download some large files 100+meg. The linux box is running vsftp. After several minutes of downloading, the connection suddenly dies, and I cannot reconnect to the box via FTP using ANY... (7 Replies)
Discussion started by: Spetnik
7 Replies

8. UNIX for Dummies Questions & Answers

Su Password Oddity

Hello Forum, I am having an odd occurence. When i do a su in a terminal or console session, I am able get authenticated as superuser without using the full or correct root password. Anyone have any idea? -AJ (4 Replies)
Discussion started by: jacobsa
4 Replies

9. UNIX for Dummies Questions & Answers

Textual oddity

This is my first post!! I really hope this question hasn't been asked a thousand times before(I'll bet it has). Anyway, here it is. I am new to the UNIX world by the way so forgive my ignorance. OK, whenever I write code on my windows machine and then try to port it over to UNIX I always get... (3 Replies)
Discussion started by: Jubba
3 Replies
Login or Register to Ask a Question