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

learn more… | top users | synonyms

0
votes
2answers
29 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
260 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 ...
5
votes
3answers
296 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
41 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
59 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
36 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
45 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
76 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
68 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
73 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
42 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 ...
0
votes
1answer
54 views

What is the full form of awk?

What is the full form of awk? I tried googling. Google doesn't answer me.
1
vote
2answers
77 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
571 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
25 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
566 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
141 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
76 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
40 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
430 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
51 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
289 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
40 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?
0
votes
2answers
52 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
63 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
303 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
171 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
62 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
88 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
39 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 ...
3
votes
3answers
3k views

Awk command to print all the lines except the last three lines

I want to print all the lines except the last three lines from the input through awk only. Please note that my file contains n number of lines. For example, file.txt contains, foo bar foobar barfoo ...
2
votes
1answer
212 views

Why does using double quotes to enclose awk's action statements produce different results than when using single quotes to enclose them?

If I use single quotes to enclose awk's action statement, it works as expected: $ dpkg -l | grep "linux\-[a-z]*\-" | awk {'print $2'} linux-headers-3.13.0-27 linux-headers-3.13.0-27-generic ...
2
votes
2answers
105 views

How to correctly invoke awk in Perl to print out the 3rd last field in a line?

My script is: #!/usr/bin/perl -w my $line="1 2 3 4 5 6 7"; print $line; my $thirdlast=`print $line |awk '{print $(NF-3)}'`; print $thirdlast; The output is: 1 2 3 4 5 6 7 awk: 0602-542 There is ...
0
votes
3answers
337 views

How can I extract user data from a file with awk and create a new user based on it?

I need somebody who could help an exercise. I can only use shell scripting and awk to do it: You have a text file called users.txt with this info inside: users.txt: Peter:7777:/home/store ; ...
3
votes
4answers
785 views

Find files with a specific 2-line pattern using awk

I have a few hundreds of files that has this pattern @<TRIPOS>ATOM 2 H18 65.2220 Du 1 RES1 0.0000 @<TRIPOS>BOND 1 3 5 ar @<TRIPOS>SUBSTRUCTURE among them, some of the files ...
1
vote
2answers
2k views

How to pass string variable as parameter to awk

I have following command: usb_soundcard_sink=$(pactl list short sinks | grep "alsa_output" | awk '{ print $2 }' | tail -n1) output of this command is: alsa_output.pci-0000_00_1b.0.analog-stereo ...
0
votes
3answers
140 views

Awk scripting help

Hey guys new to scripting and looking to see why I get the following error message: syntax error near unexpected token '$0' using this .sh file to rearrange date and time in a .txt file so that ...
1
vote
1answer
281 views

How to copy a part of a line to another position

I have about 100 print statements in a file like this: printf("%f \n\n",row1.req_pnttime); I want to copy the variable name inside the string so that it becomes like this ...
1
vote
2answers
64 views

Grab a field without a fixed position via awk

I'm working on a script to wake different LCs on my LAN. MAC-Adresses are hard to memorize so I made myself a list that contains information about the respective PCs. Right now the list looks like: ...
4
votes
2answers
188 views

Using Regex Breaking a text on the last digit using linux tools like sed, or awk

I have the following list that I want to break on the digit. For example: From: 103Ru 103mRh 104 1041 To: 103 Ru 103 mRh 104 1041 I would like to use Regx with sed or maybe awk in order to ...
4
votes
3answers
4k views

How can I process multi-line records with awk in a bash script?

example.txt is below Restaurant: McDonalds City: Miami State: Florida Address: 123 Biscayne Blvd Phone: 911 Restaurant: 5 guys City: Atlanta State: Georgia Address: 123 Peachtree Rd Phone: 911 ...
1
vote
1answer
1k views

split string with awk and delimiter

i have log file like : 1:: 10:: 127.0.0.1 172.17.1.1 i want awk to split string to columns on :: delimiter. some thing like : awk {print$1} and the result : 1 and awk {print$2} and the ...
1
vote
2answers
97 views

how to trim dpkg upgraded packages list

Latest upgrade borked my system and I`m trying to revert the last upgrade. I opened my comp with live USB and chrooted to partition that is OS installed. I get the upgraded packages with cat ...
0
votes
1answer
177 views

sed, grep, and awk file sorting

I'm trying to get all the files which have 'load' in their names from a directory. I'm trying to do: find -type f | sed -s 'load However, I recurrently receive an error sed: -e expression #1, char ...
0
votes
1answer
393 views

Download AWK to Ubuntu

How to download awk to Ubuntu, since I tried to use asorti function and it told me that there is an error on this asorti. I tried many scripts that used asorti function and the same error occure!
0
votes
1answer
275 views

Syntax error in awk program

I want to check the method of IP-Assignment as in this question. I'm running it in bash on Ubuntu 12.04. My Problem is the function "get_con_id()" gives me "Syntax error" at the if-clause. The script ...
0
votes
1answer
123 views

Concatenation in Shell Scripting Bash

I wanna check if 2 lines have equal $4 my shell must check if the diffrence between $3 in line 2 and $2 in line 3 is equal 1 it must concatenate both line into one like this 1;1000000000;1099999999;2 ...
0
votes
2answers
37 views

Sort FileA into FileB while actively removing lines from FileA

I tried simplifying the title, apologies if it's somewhat confusing. I have a large text file (File A)(around 13GB) and I want to sort through it (into File B) to delete duplicate lines. Problem is I ...
-1
votes
2answers
118 views

Reading a file line by line

I have a file that looks like: @ATDGGSGDTSG NTCCCCC + nddhdhnadn @ATDGGSGDTSG NTCCCCC + nddhdhnadn Now its a repeating pattern of "4" lines and I every time want to print only the 2nd line i.e. the ...
0
votes
1answer
45 views

Formatting a file to use it with fortune in the terminal

I have a big text file with 'Terms' and its 'Definition' separated by spaces(variable). I want to use it in fortune cookie format. Current file format: **term1** this is my definition with ...