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
3 answers

AWK - Is it possible to search for pattern, then sort results based on a wildcard?

I am storing a number of individually serialized PHP arrays to a file. Each line of the file contains one serialized array. For example: a:2:{s:4:"name";s:8:"John Doe";s:3:"age";s:2:"20";} a:2:{s:4:"name";s:8:"Jane…
tambler
  • 131
  • 1
  • 5
0
votes
2 answers

sed/awk: extract one number from string

I have many lines like the following being returned from a bash command, with different sourceNodeIds of varying digit lengths: I'd like to pipe it to sed or awk and just…
carillonator
  • 815
  • 3
  • 12
  • 22
0
votes
1 answer

How can i move or copy files (or folder) from solaris server to removable disk.(Backup Tape drive)

I need to move or copy some zip(.tar,.gz,.Z) files from Solaris server to backup tape drive. I also want to retrieve from tape drive whenever I want without any loss. Kindly explain the procedure. I have less knowledge in programming.
gyrous
0
votes
2 answers

Parse java console output with awk

I'm trying to use awk to parse an output generated by a java application, but it isn't working. It seems that the command after the pipe isn't able to get/see the data throwed by the java app. I'm executing the following command (with the return…
Bob Rivers
  • 516
  • 5
  • 13
0
votes
1 answer

How to save input colors in awk?

I've seen many more or less related topics, but all I found discuss how to color awk output. I need to preserve the color that was provided as awk input. For example, now I have: ./some_command (red_text) (blue_text) (green_text) ./some_command |…
Putnik
  • 2,217
  • 4
  • 27
  • 43
0
votes
1 answer

awk to process multiple lines and return several strings

I have these strings: Certificate Name: domain1.com Serial Number: 37aadb8fae7b908e1228c3e71 Domains: domain1.com www.domain1.com Expiry Date: 2022-11-20 02:14:29+00:00 (VALID: 3 days) Certificate Path:…
Budianto IP
  • 141
  • 6
0
votes
0 answers

GAWK not running in crontab

I have the below script running successfully manually. But when it is executed in crontab (below), I dont see anything happening. Script #!/usr/bin/gawk -f #!/bin/bash PATH=/usr/local/bin:/usr/bin #Reading from the file & storing in…
serverstackqns
  • 764
  • 3
  • 16
  • 42
0
votes
1 answer

Variable in AWK

How can I add a variable within awk command? below is my command: cat /home/ubuntu/test/copy.txt | awk 'NR==21{print ".host = "$line";"}1' $line is basically an IP address which is retrieved from a text file. With the above command the output looks…
serverstackqns
  • 764
  • 3
  • 16
  • 42
0
votes
1 answer

PHP Serialize AWK command speed up?

I've built an SQL migration script that will replace text in a MySQL dump file. Replacements would be easy with sed, but we must account for special serializations (PHP Serialize). The code below works but the awk command is very expensive. With a…
0
votes
2 answers

Running (vertical?) diff on columns in a file

in our company we pull in inventory files from third parties. These files are in a fixed format, containing the 13-digit EAN (think UPC code) as well as other data. I also have a master list of EANs in our database. I would like to compare the…
jotango
  • 475
  • 1
  • 5
  • 10
0
votes
1 answer

how can I extract a Version number from a website with curl and grep / sed?

I want to get the latets version number from this website: https://www.mailpiler.org/wiki/download so I do a curl to get the content and then just use a pipe to search for the string using grep curl https://www.mailpiler.org/wiki/download | grep…
0
votes
1 answer

Using awk with column number in a bash script

I'm using a command like this to get some connections from nf_conntrack: awk '($3 == "tcp") && ($6 != "TIME_WAIT") && ($10 == "dport=1234")' /proc/net/nf_conntrack How to use this command inside of a bash script and also add a script argument to…
ihorc
  • 43
  • 6
0
votes
0 answers

Replace a string from the cat output

I need to replace a string with the string which is mentioned in a file abcd.txt in all files in a folder. For eg: I want to replace a string 'apple' with whatever the cat output of this file abcd.txt I used the below command grep -rl 'apple'…
Am3Y
  • 67
  • 6
0
votes
1 answer

php-fpm & Apache 2 - analysing PHP Message: logs

One of my servers has recently been switched to using php-fpm. The error logs now log 404's in a new format: [Sun Dec 26 00:11:37.827426 2021] [proxy_fcgi:error] [pid 25239:tid 140600822003456] [client 66.249.66.136:37676] AH01071: Got error 'PHP…
steve
  • 153
  • 1
  • 1
  • 9
0
votes
1 answer

Can Linux do conditional judgment to insert the content at a certain line in Linux

Can Linux do conditional judgment to insert the content at a certain line in Linux? For example, I would like to add user "test" to /etc/sudoers to let it can switch to root: 1 # 2 # This file MUST be edited with the 'visudo' command as root. …
ITnewbie
  • 171
  • 2
  • 9