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

learn more… | top users | synonyms

0
votes
1answer
44 views

How can I split a line in 2 by words/characters? (Bash) (Regex)

I would like to convert: Hello Hello Hi Hello Hello Hi Hi Hi Hi Hello To: Hello Hello Hi Hello Hello Hi Hi Hi Hi Hello I want to split a single line in 2, by having them have the closest amount ...
2
votes
1answer
28 views

Join two files keeping the element order of one of them

I have two files File1 03873 03872 03871 03870 ...... File2 00001 0.867 00002 0.855 00003 0.864 00004 0.855 ... 03870 0.825 03871 0.852 03872 0.326 03873 0.852 I want to ...
3
votes
4answers
62 views

Find and replacement of the numerical part of a particular string with increased value using terminal command [duplicate]

The inputfile is, test00.dat test07.dat test03.dat aram22.dat test09.dat aram09.dat test13.dat I need the output file as test01.dat test08.dat test04.dat aram22.dat test10.dat aram09.dat ...
2
votes
3answers
181 views

How to label occurences of text?

I would like to convert blue blue red green to: color.1=blue color.2=blue color.3=red color.4=green Any leads on how to tackle this? sed, awk, etc.?
0
votes
1answer
47 views

awk print output redirection

I am writing a bash script, and in that bash script I have a line similar to this: awk '/TextToBeMatched/ { print; print "TextToInsert"; next }1' "/Path/to/specified/file.extension" And currently ...
0
votes
3answers
50 views

Substitute specific char sequence inside filenames

A friend of mine grouped tons of files in this way on windows After I made him switch to Ubuntu, files are no more ordered based on the number of exclamation marks in front, so I would like to know ...
4
votes
2answers
94 views

Print a group of lines if they contain specific strings

I have a file (file 1) that looks like that: >C 0 0 4231aa, >A6_03412... at 1:4226:1:4240/95.44% 1 4240aa, >A5_01600... * >C 1 0 4159aa, >FG1_03697... * >C 2 0 3942aa, ...
2
votes
4answers
246 views

Repeat each line in a text n times

I have a file that looks like this 888 924 873 1374 ..... The dots indicate that I have many more string, around 3000. I want repeat each string n time, to have something like this; 888 888 888 ...
2
votes
2answers
30 views

awk: matching strings to decimal values and summing them

I have strings that are supposed to match with numbers. For example, one is equal to 1 Now, I have a file that separates columns with ; and I want to write an awk expression that checks if the SUM ...
2
votes
4answers
164 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
124 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
29 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 { ...
0
votes
1answer
51 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
25 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
235 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
68 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
104 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
28 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
311 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
87 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
56 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
17 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
55 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
169 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
234 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
81 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
44 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
46 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
585 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
823 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
112 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
85 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
95 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
61 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
81 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
459 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
100 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
51 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
159 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
167 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
5answers
590 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
49 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
703 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
272 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
186 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
54 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
54 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
396 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
53 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?