AWK is a text-processing language. It is mainly used to manipulate and process structured data, and to generate reports.

learn more… | top users | synonyms

2
votes
2answers
193 views

Count elements in lines with awk

I have a tab-delimited text file containing data like Col 1 Col 2 1 a 1 b 1 c 1 d 1 d 2 a 2 b 3 a so on and so forth. I would like to transform this structure into ...
1
vote
2answers
777 views

Sum a particular column and take the unique record of another using AWK only

I have an input file like the following: 19 | 17 | 1 | 89 | C | 9 | 100 | 9 | PL | 2175 20 | 17 | 1 | 89 | C | 9 | 100 | 9 | PL | 2175 21 | 17 | 2 | 89 | C | 9 | 100 | 9 | PL | 2175 23 | 17 | 2 | 89 ...
1
vote
2answers
454 views

How to pass bash variables (passwords) to IRSSI config file?

I'm using IRSSI and I wonder how can I pass my IRC channel's passwords to the IRSSI config file (~/.irssi/config) without writing them directly in the file. In Mutt I've an awk command that queries a ...
0
votes
2answers
50 views

Extending awk one-liner from identifying matching pair of columns (row by row), to multiple columns

I am using Win7 with Cygwin. I have a one-liner that will work for identifying matches in a PAIR of columns, but when I try to introduce additional columns (i.e. >2) I cannot get it to work. So the ...
0
votes
2answers
68 views

How to copy file using awk based on time creation to some directory

I trying to copy a file to directory using awk filter based on time creation file #!/bin/bash dir=/home/resaputra23/pyexample/python2/* des=/home/resaputra23/pyexample/backup/ file1= stat $dir | awk ...
0
votes
2answers
30 views

quote-enclosed fields in input to awk

I'm trying to process a webserver logfile in awk. Like 123.222.333.444 - - [24/Feb/2015:13:09:19 +0100] "GET / HTTP/1.1" 200 15852 "https://www.google.dk/" "Mozilla/5.0 (Windows NT 6.1) ...." ...
0
votes
2answers
112 views

Text deletion between patterns across multiple lines with respect to text inside pattern

I have a block of text I need to delete, however, only if it contains specific text inside the block: ... <script language="JavaScript"> var somethingA = 0; var somethingB = 0; var ...
4
votes
1answer
59 views

writing an AWK command

My input file has three columns like the one below Input file: water 123 wa water 123 at water 123 te water 123 er rater 347 ra rater 347 at rater 347 te rater 347 er ...
1
vote
1answer
155 views

How to convert a column of hex to dec in gawk, strtonum in gawk gives erroneous results

I am trying to script a database from a network stream. The network stream after being heavily sed'd drops a three column file that looks something like this called file.db ...
1
vote
1answer
231 views

How to replace a line in an xml file with a set of lines stored in a variable or file using unix commands?

I have a xml file in which the line that needs to be searched is: SEARCH='<?xml version="1.0" encoding="UTF-8" standalone="no"?><SSC>' This searched value needs to be replaced with ...
1
vote
1answer
313 views

printing only first finded match

I've created a statement which is searching for specific informations in each line (in my case "AAA","BBB" or "CCC"), if there is no such information N/A is printed { k=0; for (i=1;i<=NF;i++) ...
1
vote
1answer
312 views

error occur when i run awk command write in .sh file and run in cygwin terminal

i have cygwin terminal for run shell script(.sh ) file...it work good..but when i add awk command in shell script and then run Error occur /usr/bin/gawk.exe: error while loading shared libraries: ...
1
vote
1answer
485 views

Transform single column to multiple columns based on values

I have 1 column like below: AAA 999888 BBB 1111 BBB 2222 AAA 999777 BBB 3333 AAA 999666 BBB 4444 CCC Doit ... Consider above up to a few thousand rows. I want to convert it to below 3 column table ...
1
vote
1answer
796 views

How to solve “Broken Pipe” error when using awk with head

I'm getting broken pipe errors from a command that does something like: ls -tr1 /a/path | awk -F '\n' -vpath=/prepend/path/ '{print path$1}' | head -n 50 Essentially I want to list (with absolute ...
0
votes
1answer
43 views

Get the Group name which has GID=0

I wanted to write a shell script in which it needs to give the group name whose GID=0.I used awk command like this, awk -F ':' {$3==0} /etc/group | cut -d ':' -f1 It works fine in redhat,aix.But ...
0
votes
1answer
42 views

Replace with sed a tag value under a specific section when matching a line

I would like to change a line when another line matchs under a section of a file using the sed command (or awk). Here is an exemple of the file : Extract of MyFic.txt : <PlayList> ... ...
0
votes
1answer
144 views

Awk script to run a command based on condition using 'if'

I have a piece of code here that basically takes a file called 'srcip' (which is just a list of IP addresses) and compares it to my '~/db' file which is just a tab delimited IP HOSTNAME database of ...
0
votes
1answer
73 views

Extract text between two slashes and add it at the end of the line after a tab character

I have a text file looking like this: data/CON/001/raw_series_ST_MC_REG_SM.nii data/PAT/001/raw_series_ST_MC_REG_SM.nii I would like to achieve something like this: ...
0
votes
1answer
99 views

word boundary in a awk command not working when printing a range of lines

I am attempting to parse samba .conf file for a specific share section... [CMI] oplocks = no wide links = no writeable = yes delete readonly = yes path = /LOCALSITE/CMI ...
0
votes
1answer
42 views

Using Grep or AWK to find all of the occurences of a specified string

I have a massive single line of data and I am trying to find the occurrences of a specified string. I then want to export the occurrences (-/+) 20 characters to another file. Can anyone offer a ...
0
votes
1answer
442 views

How to add a prefix to every row of a particular column in a csv file via command line on linux

So basically i am trying to achieve the following.    File before editing.  column-1,   column-2,  column-3,  column-4,  column-5 Row-1-c1, ...
0
votes
1answer
123 views

How to grep values under columns

How can I grep for a specific column name and display the value underneath that column. Sample data: StandByFile StandByPg StandByLSN StandByRcvBufUsed S0082160.LOG 621668 ...
0
votes
1answer
73 views

awk used with grep - no output

I have a bashscript which uses grep with awk as following: #ec2-describe-instances | grep -i instance | awk '{print "Creating -> " $3; system("ec2-create-image " $2 " --name " $3 "-$(date +%F) ...
0
votes
1answer
193 views

Bash Sum Average numbers in files

I have a series of files with 2(two) lines. The first line contains a whole number (1-100) while the second line contains a decimal number(1.0000-99.9999). I need to get the sum of the first line and ...
0
votes
1answer
102 views

How to encrypt the mail in unix?

I want to encrypt the mail as that will be containing the confidential information. There are no attachments. Please help in providing the steps to encrypt the mail. I have got the reference of How ...
0
votes
1answer
146 views

Why is this awk statement not working?

awk 'BEGIN { COLM_FMT = "%-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s,\n" } { printf COLM_FMT, ${totals[0]}, ${totals[1]}, ${totals[2]}, ...
0
votes
1answer
83 views

trying to extract two tables at a time from http files with 40 tables each

I have about 20 webpages. Each page has top banner navigation and then has information on up to 20 vehicles. There are 2 tables per vehicle. The logical flow is: page navigation, table 1 for ...
0
votes
1answer
167 views

redirect awk information to stdout

I am trying to gather information for CPU use for all the processors in a text file. mpstat -P ALL -u 1 | awk '{print $4}' > cpu.txt && mptat -P ALL -u 1 | awk '{print $4}' | tee cpu.txt ...
0
votes
1answer
485 views

Mass migration of EXIF GPS data (a.k.a. Escape from iPhoto)

I am trying to move my library of photos (over 12000) out of iPhoto for use in Adobe Lightroom and would like to include the GPS data I've added to the photos using iPhoto's in-app feature (This data ...
0
votes
1answer
268 views

Counting duplicates lines from a stream

I'm currently parsing apache logs with that command: tail -f /opt/apache/logs/access/gvh-access_log.1365638400 | grep specific.stuff. | awk '{print $12}' | cut -d/ -f3 > ~/logs The output is a ...
0
votes
1answer
135 views

Bash script is printing wrong characters in my variable

I'm trying out the following thing in my terminal: spark 0 76 100 | awk '{print substr($0,4,3)}' outputs: ▆ If I do: GRAPH=$(spark 0 25 100 | awk '{print substr($0,4,3)}') printf "%s" $GRAPH ...
0
votes
1answer
247 views

Filtering output from the “dscl -readall” command

dscl . -readall /Users outputs something like this (only a part of the entire output): PrimaryGroupID: 20 RealName: Johnny Smith RecordName: johnny RecordType: dsRecTypeStandard:Users UniqueID: ...
0
votes
1answer
137 views

how to get access to environment variables from output file

I want to get variables from a output file specific location,and input file format as below: log1.txt format: [v] Output Data ...
0
votes
1answer
1k views

Getting the week number based on date with different first day of the week in gawk

How to get the week number in linux using gawk with different first day of the week? the date command can give me the week number with +%V but it is based on Monday (1-53) or +%U (based on Sunday, ...
0
votes
1answer
866 views

Solaris bash script / search and append field to end of line in /etc/group

I need a bash script that will modify /etc/group to append and delete NIS users to specific local groups on a Solaris 10u8 system. Preferable one or two functions with uid and groupname as varibles. ...
-1
votes
1answer
44 views

editing column of a text file

abc.txt consists of two column data as 1 A1021 2 A1021 3 A1022 4 A1022 I want another test file, say pqr.txt (replacing A1021 by 1 and A1022 by 2 and so on). I used the following usual perl ...
-1
votes
1answer
36 views

Which regular expressions (POSIX or extended) are allowed in awk?

I'm wondering which kind of regular expressions (POSIX as in grep, or extended in egrep) am I using when type in regular expressions in awk?
2
votes
0answers
264 views

stdbuf not working while unbuffer does

I am trying to apply timestamps to stdout of a process. For the proper timestamps to be applied, I attempt to unbuffer stdout of the process. This works with unbuffer but not with stdbuf as I would ...
1
vote
0answers
69 views

Automatically Split a Huge TeX File Into Many Smaller Files

How would I automatically split the sections or chapters of a huge TeX file into many smaller TeX files? This somewhat works: awk -v RS='\\chapter{' '{print "\\chapter{"$0 > (NR".tex")}' ...
0
votes
0answers
8 views

Mac OS X Find and Replace API

Are the Find and Replace operations under the Edit menu in Acrobat or Word simply a front end for the unix awk, sed or grep commands? Where can I find more information about what's going on underneath ...
0
votes
0answers
35 views

Multiple replace - using sed or awk

I have a code snippet like below CREATE TABLE TABLE1( ID integer NOT NULL, ROW_CREATED varchar (26) NULL, BATCH_LOG_ID integer NULL, TRANSACTION_TYPE varchar(5) NULL, PARTITION_COL integer ...
0
votes
0answers
21 views

Strang, same simple awk script has different results on different machines

This is the strangest mystery ever -- same simple awk script has different results on different machines. The awk script is really simple: $ cat awk_test.awk BEGIN { troubleshoot = 1 } # GET: ...
0
votes
0answers
78 views

Copy huge file skipping first line using dd in Linux

I was trying to copy the content of a huge file (10GB) to another skipping the first line (as in head -n1). I tried multiple ways of head, tail, awk and sed. Settled on using tail -n+2 > ./xab.1 ...
0
votes
0answers
51 views

awk remove sign “,” in all columns, if it exists between

My data input file: 508,186,,Name,"VIA PAS, 4",vou1@mail.com, 291,345,,Name2,Votros 73,vou2@mail.com, 911,733,,Name3,zap 101,vou4@mail.com, 9000,32,,Michel,hops 12,"x1@mail.com, vou7@mail.com, ...
0
votes
0answers
41 views

several awk commands consecutively

I'm using awk command to extract some datas. The point is that I need to use awk command several times to extract all informations I need and each time when I'm using awk I need create a temp file. My ...
0
votes
0answers
127 views

XML text transformation

I have a large file part of which is like below: <DataGroup xsi:type="ReportDataGroup"> <SmartReportTemplate DescriptionContentType="text/plain" IsActive="true"> <Name ...
0
votes
0answers
187 views

How can I improve or wrap my sed-script?

I instrumented a mvn build to emit profiling data, which I want to analyse later on. Therefore, I made the sed script below, to generate json-data from the profilers output. I call the script with ...
0
votes
0answers
306 views

Reset awk field separator

On my local system, it appears that the configuration for awk has somehow been changed. Running the following command: echo "Hi there" | awk '{print $2}' On my machine this prints: Hi there And ...
0
votes
0answers
745 views

awk+regex with GUI on windows?

Sometimes i have text copied from a doc or a browser which i need to process. I figure awk would solve it and maybe a little regex to help. Is there something like this? or do i need to find a ...
-1
votes
0answers
14 views

What does cygwin delete when I install new packages?

I would like to install new cygwin packages, however, I obviously want to keep my old ones. I selected the new packages that I wanted to use (gawk, et. al.), and installed again. However, this ...