Questions tagged [awk]

The AWK utility is a data extraction and reporting tool that uses a data-driven scripting language consisting of a set of actions to be taken against textual data (either in files or data streams) for the purpose of producing formatted reports.

The AWK utility is a data extraction and reporting tool that uses a data-driven scripting language consisting of a set of actions to be taken against textual data (either in files or data streams) for the purpose of producing formatted reports. The language used by awk extensively uses the string datatype, associative arrays (that is, arrays indexed by key strings), and regular expressions.

AWK was created at Bell Labs in the 1970s, and its name is derived from the family names of its authors — Alfred Aho, Peter Weinberger, and Brian Kernighan.

194 questions
0
votes
2 answers

Extract text between 2 strings only if another string is present

I have a quit large XML file that I am trying to modify only certain lines of the file. The lines I want to modify will all contain in them. On those lines, I want to have only the text between 2 string (in this case those strings are / and ). So…
0
votes
1 answer

Using sed to remove "(double-quotes) on code lines while leaving them on real comments in a vimrc

I'm finally learning how to use sed to edit configs while installing Ubuntu(Server/Desktop). After much gnashing of teeth and searching about for the proper syntax to not remove the "(comment double-quotes with exactly one blank space afterward(real…
0
votes
1 answer

delete some char set from the last column linux

I want to the delete everything after hyphen "e-" in the last column output.. Below is what my output looks like.. # awk '/out: OpenSSL/ { gsub( /[][]|out:/ , "" ) ; print $1,$2,$3 }' sslcheck.log | column -t myserver1 …
Karn Kumar
  • 105
  • 4
0
votes
0 answers

sed + delete duplicate lines except the first one according to specific request

in /etc/services file I can see duplicate lines for example the following line is duplicate ( or more ) odasrv 2432/udp so it can easily deleted by sed as the follwing sed -i '/codasrv 2432\/udp/d' /etc/services but the problem…
shalom
  • 461
  • 13
  • 29
0
votes
4 answers

do... while loop in original 1978 awk?

Does the do... while loop work in the original awk? Or has it been introduced in later implementations (nawk, gawk, ...)? Can nawk be considered present on all Unix platforms today? Greets, Oliver
Trollhorn
0
votes
2 answers

replacing space with new line characters for vagrant box use

I am trying to setup vagrant box using shell script where in I am storing key and cert files. Normal format of any cert or key file is as below -----BEGIN…
Shailesh Sutar
  • 1,517
  • 5
  • 23
  • 41
0
votes
2 answers

How to insert a complex line between two single quotes in sed?

I have this line in the file /var/lib/pgsql/data/postgresql.conf: # archive_command = '' # command to use to archive a logfile segment we need to uncomment the archive_command parameter, and set its value to 'rsync -a %p…
jango
  • 59
  • 2
  • 3
  • 12
0
votes
0 answers

Nagios php script to read iostat values

I'm working on a php script(nagios plugin) to read r/s,w/s,rMB/s,wMB/s,%util from the iostat command, e.g. #iostat -xm sda avg-cpu: %user %nice %system %iowait %steal %idle 1.05 0.08 1.16 6.24 0.00 91.47 Device: …
user387821
0
votes
1 answer

Parsing the time data from last command which has total "00:00" time spent on the last column

I have last command output for the hundred of Servers collected into the File,the problem is now is output is "Feb,Jan,Feb" meaning that its taking the Feb output of last years as well, So, i'm looking around the way if i can get the output With…
krock1516
  • 128
  • 1
  • 5
0
votes
1 answer

list services and store them in array bash

I want to list all services from /etc/init.d/ and grep pattern and store them in array. for instance like below. ls -la /etc/init.d/ | grep example-subs | awk '{ print $9 }' example-subs-sidekick example-subs-unicorn and store the strings in array…
Shailesh Sutar
  • 1,517
  • 5
  • 23
  • 41
0
votes
2 answers

Replace a string once another string has been found

I'm programmatically building boxes, but I need to update a .repo file for PHP which has the following contents: # Repository: http://rpms.remirepo.net/ # Blog: http://blog.remirepo.net/ # Forum: …
Brian Brownton
  • 113
  • 1
  • 5
0
votes
1 answer

Date format conversion to epoch using gawk ( awk )

I want to convert dates in a file to epoch time. A sample csv looks like this: $ cat test.jtl 2016/09/19 00:31:17.080,238,test1 2016/09/19 00:31:17.154,322,test2 22-Sep-2014 10:32:35.012,222,test3 I have tried the following , but the result…
user376778
  • 9
  • 1
  • 2
0
votes
1 answer

How to combine lsof stat and ps to get more info in one line bash command

I can use lsof to get top open files stat for processes, as below: $ lsof -n|awk '{print $2}'|sort|uniq -c|sort -nr | head -n 5 17955 11945 10282 2786 5980 32152 1920 27803 1786 32107 Now I want to expand the result to like below with…
Y.Huang
  • 11
  • 1
0
votes
3 answers

Matching first block of text from a file, between 2 strings

I'm trying to match only the first block of text between 2 strings: 'menuentry ' and '}' from a file as follows: Input file: (some irrelevant text) menuentry 'My Customized Linux, with Linux 3.10.0-229.14.1.el7.x86_64' --class centos --class…
adiflinux
  • 33
  • 5
0
votes
2 answers

Prepend String using perl/awk/sed?

I'm trying to script a change to my apache config file (httpd.conf). I'm trying to match the following string: # # DirectoryIndex: sets the file that Apache will serve if a directory And PREPEND the following text: # # Allow server status reports…
Brad
  • 619
  • 1
  • 10
  • 28