Quantcast
Channel: Question and Answer » gawk
Browsing latest articles
Browse All 13 View Live

Multiple input files and output files in awk

I have a folder full of text files named 000.txt to 181.txt. How can I process all of them with the same awk script (program.awk) and send them to their respective output files (output000.txt –...

View Article



Help reg to write gawk script [closed]

Need sample gawk to join two records with unique key $2.$1 has different entity eventhough $2 is key thats why there are ther are two different lines for same key I/p FIle not in sorted order...

View Article

Using awk to process a mapping file with dynamic number of columns

I’m a complete newbie to awk and am wondering how to process information as following: mapping.txt: 80 001 002 81 011 012 013 014 82 021 022 ... input.txt: 81 103823044 80 103823054 81 103823064 ......

View Article

Escape sequences passed as args to gawk not interpreted

I want to be able to pass an argument on the command line to gawk that is evaluated for escape sequences. The issue: $ gawk 'BEGIN { print ARGV[1]; }' 't' t Instead, I would like to get an actual tab...

View Article

Why can't a constant regular expression be put on the left side of an ~...

Why cant I put a regular expression on the left side of the ~ operator when using gawk. For example, given the file below with fields delimited with tabs(t): $ cat cats siberian 1970 73 2500 shorthair...

View Article


Conditional if clause in awk

Please consider below file: foo,1000,boo,A foo,1000,boo,B foo,1001,boo,B foo,1002,boo,D And we have below rules: If $2 equal 1000, $4 should be equal A If $2 equal 1001, $4 should be equal B If $2...

View Article

Find matches from an index file without exact matching and print the last field

I have a large file (~6mill rows) with 2 columns which looks like this: 1111.aaaaabbb.b.cccc.c ValueA 2222.dddddeee.e.ffff.f ValueB 3333.gggghhhh.h.iiii.i ValueC I want to use that as my index when...

View Article

Combine range of columns with the same key

Input file tab separated: A |B | C | KEY | D| E| F |G | H | I | J | k | ----|----|----|------|---|---|-----|------|---|---|-----|-----| word|word|word| one | 8| 8|qw123| "" | ""| ""| word| word|...

View Article


split file into multiple pieces

Problem: given a file samplein, it can be split up into multiple pieces as follows: $ cat samplein START Unix Linux START Solaris Aix SCO $ awk '/START/{x="F"++i;}{print > x}' samplein $ ls F* F1 F2...

View Article


What is a *.sorted command and why doesn't it work in my bash?

In a Bash Guide for Beginners (sec. 3.2.1.2. Local variables) there is an example command which is supposed to list all of the local variables, that are not in enviromental variables, or so I think:...

View Article
Browsing latest articles
Browse All 13 View Live




Latest Images