awk is a special-purpose, interpreted programming language for extracting and reporting data.

learn more… | top users | synonyms

2
votes
4answers
92 views

count the number of unique values based on two columns in a spreadsheet

I need to count the number of unique values based on two columns in a spreadsheet. Suppose the file looks like this, ordered by name, surname, company: joe allen ibm joe smith ibm joe allen google ...
0
votes
1answer
94 views

Printing from arrays vs awk 'NR

I am currently printing out values from vmstat stress tests using this: vmstat -a $INT $CNT | awk 'NR > 1 {print $13,$14,$15}'> vm.log_$D & sleep 5 && stress --vm $cores -t ...
-2
votes
0answers
22 views

print values from stress to an array-syntax error {

I am trying to print values that I have obtained from running vmstat with stress using awk. However, it may look tidier when I use arrays so I edited it again. Now it is giving me a syntax error of { ...
-3
votes
1answer
41 views

How to find and replace a particular string in the following manner

My input file is, ami0041 ami00056 ami0029 ami023 ami0099 ami049 ami00999 tumi0234 bichi23455 susami345 Using a single command line I need the output as, ami0042 ami00057 ami0030 ami024 ami0100 ...
0
votes
1answer
37 views

How to find and replace a particular string by increasing its numerical part?

My input file is, ami41 ami56 ami23 ami67 ami45 ami34 ami88 jama66 tumi234 bichi23455 susami345 Using a single command line I need the output as, ami42 ami57 ami24 ami68 ami46 ami35 ami89 jama66 ...
0
votes
1answer
14 views

grep single pattern having more than one matches

I have a file (X.txt) with a list of unique entries. I would like to use this file to grep from another File Y.txt which contain more than one entries for single pattern of X.txt. X.txt contains: ...
3
votes
3answers
208 views

How to find and replace a string by increasing its numerical part?

My input file is, ami21 ami65 ami67 ami66 ami88 ami76 ami29 ami55 ami54 ami32 Using a single command line I need the output as, ami22 ami66 ami68 ami67 ami89 ami77 ami30 ami56 ami55 ami33 I ...
-2
votes
2answers
65 views

AWK is not printing the result

I want to write a simple awk command in Ubuntu (version 14.04), but it is not returning anything. $ cat sample.csv 001,Text1,Val1 002,Text2,Val2 003,Text3,Val3 $ cat sample.csv|awk -F',''{for ...
1
vote
2answers
91 views

Grep strings in a subgroup of lines in txt file

I have a file that looks like this AAA_21 PF13304.1 x_00004 AAA_22 PF13401.1 x_00004 SMC_N PF02463.14 x_00004 AAA_29 PF13555.1 x_00004 ...
1
vote
1answer
23 views

Awk variable passing question

This is the code I wrote to resolve DNSs and output to a file. Is there a way to forgo the while loop entirely and just write in awk? It works perfectly but it seems very cumbersome and inefficient, ...
-2
votes
1answer
53 views

compare strings in two files and update the status [duplicate]

i have following data set in text file data.txt: d1,40,gold d2,30,silver d3,20,bronze d4,10,iron d5,5,wood d6,20,gold d7,10,wood d8,5,god d9,10,silver . . . ...
2
votes
1answer
122 views

bash comparing multiple column in two files with different length

I have following data set in text file data.txt d1,40,gold d2,30,silver d3,20,bronze d4,10,iron d5,5,wood d6,20,gold d7,10,wood d8,5,gold d9,10,silver . . . def.txt gold,40 silver,30 bronze,20 ...
1
vote
2answers
58 views

bash text colon values to html table

i had a big file with more than 10000 recordslike below, this need to be converted to html table i tried various ways with converting into csv and then to html etc.., not able to get the desired ...
1
vote
2answers
45 views

How to print both matching lines from two different files? [duplicate]

I have file1 and file2 as following. I would like to first find matches between two files based on first column and then print the matching lines from file1 and file2. I have written the desired ...
0
votes
1answer
16 views

Extracting latest googleAppEngine with curl + awk

I am trying to extract the latest version of google app engine from their catalog. To do this I am using curl + awk. I found that the following regex extracts what I need: ...
0
votes
1answer
53 views

stripping a string using awk

input string prashant@prashant:~/Desktop$ xyz /123/ {print } abc.txt after using awk command to strip on above input string I should get below output string xyz /123/ {print } abc.txt
1
vote
1answer
99 views

cat vs grep vs awk command get the file content which one is more efficient and less time consuming?

Lets say I have file content like this: this is a simple file for testing purpose with few lines in it. to check the cat and grep command to verfy which is best and less excution time consuming ...
4
votes
1answer
175 views

Choosing awk version on Ubuntu 14.04

I am using Ubuntu 14.04, and making heavy use of all the great commands awk, sed, sort and so on. Recently it came to my attention that Ubuntu uses mawk as the default implementation, but since I ...
-1
votes
1answer
80 views

Making use of awk on string [closed]

I'm interested in listing in the terminal the lines from a csv file where the first character is 'A' . Is there a prompt way to do that?
0
votes
1answer
43 views

What is the purpose of '/' in awk command?

Why does this works : echo 'NetRange:192.168.1.1-192.168.255.255' | awk -F: '/NetRange/ {print $2}' and this doesn't echo 'NetRange:192.168.1.1-192.168.255.255' | awk -F: 'NetRange {print $2}' ...
1
vote
2answers
42 views

How does awk -F work?

Can you please explain as to how the followin piece of code works? l_Basename="hello_world.ksh" l_THIS_FILE=`echo $l_Basename | awk -F. '{field=1 while (field < NF) { ...
3
votes
6answers
457 views

rename multiple files with delimiters

How could I rename multiple files like, IonXpress_049.T11014.R_2014_11_13_11_26_35_user_PR2-41-Pooling0026_3140_13112014.bam ...
4
votes
4answers
654 views

How to find all patterns between two characters?

I'm trying to find all patterns between a pair of double quotes. Let say I have a file with contents look like as following: first matched is "One". the second is here"Two " and here are in second ...
2
votes
2answers
84 views

awk command while ((getline < “gpsoutput.tr”) > 0 for constantly updating file contents

I am currently using a G-STAR IV globalsat GPS which gives me the following output (which is coming from the GPS every 1 second) and I save this output by redirecting to a file name "gpsoutput.tr". ...
1
vote
3answers
77 views

csv file adding and removing characters from rows [closed]

I have a big csv full that looks like so else if(a,b,c,d,e) else if(a,b,c,d,f) I want to make it look like so else if(a+x==b and b+x==c and c+x==d and d+x==e) else if(a+x==b and b+x==c and c+x==d ...
1
vote
1answer
83 views

why my bash script only outputs one line on echoing awk variable

Anyone can probably tell I'm new at scripting and have tried doing as much homewaork before posting here. I have what I think is a simple script parsing out DNS zone file for IP and unique domain ...
0
votes
2answers
55 views

AWK counting back

I have a list of domains matched and piped in through grep with various length but all match the last three records. I'm trying to output all of the non-qualified sub-domains. I have: awk -F'.' -v ...
1
vote
3answers
80 views

Replace a specific section of code

I don't know what could do this, sed, vim, whatever. Lets say I have 30 functions, to keep it simple, i'll show 3 #first function AddOne = [ a+1==b, b+1==c ] # second function ...
1
vote
3answers
308 views

Deleting column in vim

I have a tab-delimited file like: name1 verb1 name2 verb2 etc... I want to delete the second column. I tried editing one of these answers, but being not familiar with sed and awk, I ...
1
vote
2answers
96 views

Looping through csv, removing patterns

I have a question similar to my earlier question, but a bit different say you have 10 columns on each line, and 100000 lines, I want to check if each row for the following patterns: If a row looks ...
2
votes
1answer
49 views

How to show the latest bzr revision number of a branch

I'd like to get the latest revision number of a given bzr branch on the console, and I'm wondering if there is any bzr command that does that for me. For now, I'm thinking of just running bzr log ...
-1
votes
1answer
125 views

What is the full form of awk? [closed]

What is the full form of awk? I tried googling. Google doesn't answer me.
1
vote
2answers
141 views

Evaluate Expression within awk

I want to create a conditional expression string and pass in an awk script. My script is as below... comm="\$3 == "hello"" awk -F "^T" -v command="${comm}" ' { if ( command ) { print "hye" ...
8
votes
6answers
584 views

Only get the H+W geometry of my screen without the later +x+y

I am reading this article. There is a statement there that goes: ffmpeg -f alsa -ac 2 -i hw:0,0 -f x11grab -s $(xwininfo -root | grep 'geometry' | awk '{print $2;}') -r 25 -i :0.0 -sameq -f mpeg -ar ...
0
votes
2answers
40 views

How can I make DNSMASQ bindings in human readable format?

I want to setup an alias or a script that will allow me show the DHCP bindings dnsmasq has. $ cat /var/lib/misc/dnsmasq.leases 1411349054 08:11:96:e9:52:ec 192.168.1.96 W11837894 * 1411413528 ...
6
votes
4answers
663 views

how to delete line numbers in a code block?

Generally codes published in web pages contains line numbers. When I copy and paste code into text editor (though some text editors remove line numbers automatically, but somtimes it doesn't work), it ...
0
votes
1answer
236 views

Linux : Data extraction from text file

I have a text file in which thousands of data is there. eg. id=row_value profile=row_value name=row_value email=row_value address=row_value id=row_value2 profile=row_value2 name=row_value2 ...
0
votes
1answer
143 views

return value from awk

This is mybashfile.sh file . . . awk -f myawkfile.awk mytracefile.tr . . . Now I want to return one parameter from myawkfile.awk to the current mybashfile.sh. Is there any way to return a value ...
2
votes
2answers
48 views

access to field's element via awk

I have the following columns: _111_ [555] _222_ [666] _333_ [777] _444_ [888] I want to access the 111 from _111_. or 888 from [888]. How to access the fields elements with awk.
0
votes
1answer
1k views

access to column in python like awk [closed]

This is my data file: Iam python newbie If I use awk to access columns element, that is easy just by $1. how can I access this columns element on python?
0
votes
1answer
53 views

one column from output column on awk

Suppose which I have this table: one two three four two three four five three four five six four five six seven five six seven eight so I wrote awk -v word=two '$0 ~ "[^[:alpha:]]" word ...
3
votes
2answers
349 views

Find a word using AWK

Is there a way to find a specific record among the whole line? This is my file: one two three four two three four five three four five six four five six seven five six seven eight How do I search ...
2
votes
1answer
51 views

How to print all coloumns using AWK

In AWK, is there a way to print all columns? I do not want to print them like this: printf($1 $2 $3 ...) Is there a way to print all of them?
1
vote
2answers
55 views

awk search help [closed]

I need help with a simple awk script for matching letters on a lines. For example, Finding separate matches for KJ in one field and finding matches for KP in the next? Name VT Kip ...
0
votes
1answer
115 views

How to filter grep results?

I am new at writing scripts. So I am hoping this is simple. The script I am writing is used to gather system information and save it as an html file. When I run: sudo lshw -short it list all of ...
0
votes
1answer
367 views

New PHP5.3.10 update error

After receiving the latest announcement about security vulnerabilities of PHP5 (Ubuntu Security Notice USN-2254-1) I decided to upgrade my server, but I ran into some problems. The new packages listed ...
1
vote
1answer
181 views

using awk to print variable in loop

I am beginner in working with bash script. I have a data file: i z r 0 -30 3.5 0 -29.5 3.4 0 -29 3.6 ... ...
0
votes
1answer
82 views

Can someone explain what this grep/cut/awk command is doing

This is inside of a .sh script file: cd /somefolder IP=$(ifconfig | grep 'inet addr:'| grep 168 | grep 192|cut -d: -f2 | awk '{print $1}') The /somefolder has another folder list with a single ...
0
votes
2answers
104 views

Speed up script

Which shell command is the fastest way to parse through millions of lines of text. Currently I'm using GREP in my script but it takes hours upon hours to finish. Sample Input: May 1 2014 00:00:00 ...
1
vote
3answers
42 views

Document Sorting Section

I have some sample data below (call it test.txt). I would like to split this big document into 3 documents by searching the first two digits in the 4th column. I'm pretty new with Linux (Lubuntu ...