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

learn more… | top users | synonyms

1
vote
1answer
24 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
41 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
2answers
63 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
53 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
65 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
38 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
41 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
64 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
566 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
24 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
541 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
72 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
61 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
39 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
198 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
47 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
267 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
34 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
47 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
242 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
168 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
56 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
83 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
2k 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
123 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
73 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
196 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
670 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
1k 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
112 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
199 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
58 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
164 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
3k 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
87 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
164 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
210 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
256 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
115 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
111 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
39 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 ...
2
votes
3answers
153 views

Print multiple lines starting with “D” after multiple greps

I have two text files. Text-file-1 contains strings (one string per line); C 010 C 020 C 024 . . . Text-file-2 contains data in following format; C 005 Carbon D Carbon 1 D Carbon 2 D Carbon 3 D ...
9
votes
2answers
6k views

What does this command mean: awk -F: '{print $4}'?

Please explain what does following command mean: awk -F: '{print $4}'
2
votes
4answers
283 views

Using if an AWK command

I have a file which contains many sub-sections each starting with [begin] and ending with [end]sample of which is shown below: [begin li1_1378184738754_91] ...
2
votes
2answers
639 views

How to write an awk script that catch ping's time

In this line: Reply from 10.11.12.13 time=1035ms how to write an awk script which brings out just 1035.
2
votes
1answer
205 views

Subtitle Overlapping: How to comparing two timelines in subtitles (e.g. 00:18:06 vs 00:16:01) and overwriting one of them if it's overlapping?

I have a series of srt files (film subtitles) that some of their time-lines overlap each others on the video! This means that some of time-lines are displayed about 1-2 seconds longer than they are in ...