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.
200 questions
1
vote
5
answers
564
views
Remove commas in double quotes from CSV
I have a comma separated line I am using awk to extract fields from.
Server1,poweredOn,10.0.18.70,"Blue, Green",POC,Vsphere
However, when it comes to the text in double quotes ("Blue, ...
0
votes
1
answer
109
views
sh Script Syntax Assistance
I'm trying to write a script that will read search strings from an input file and then execute a command with $string in the middle of the command line. This is an example of the working command line:...
0
votes
2
answers
376
views
Format and filter ibm-mq queues
I need to display each IBM MQ Queue Manager queue along with its depth.
I can do this with a command like echo DISPLAY QLOCAL(QE*) WHERE(CURDEPTH GE 0) | runmqsc QMNAME.
The output is similar to this:
...
0
votes
2
answers
170
views
Kill processes longer than 1 hour matching a pattern
I am having an issue in a PHP application, where some processes seem to run for days - still trying to work out how/why but, whilst this happens, the resources on the server get zapped and loads goes ...
0
votes
1
answer
123
views
Change item in Apache configuration file with `awk`
I am not an expert with awk tool. I must miss something obvious...
What works so far:
[root@checkmk ~]# awk '/^[[:blank:]]*SSLCertificateFile/ {gsub(/\/etc\//, "/not_etc/")} 1' \
/etc/httpd/...
0
votes
2
answers
703
views
Bash script : Print all lines between two pattern in variables with slashes
I have a directory that looks like so :
/path/to/files/data-file.1
/path/to/files/data-file.2
/path/to/files/data-file.3
/path/to/files/data-file.4
/path/to/files/data-file.5
/path/to/files/data-file....
2
votes
3
answers
835
views
Best way to filter output by date range
I need to filter a row of a csv file by a date.
The file is structured as so:
[email protected] active 01/24/11 10:04 07/23/23 16:56
...
2
votes
1
answer
651
views
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
(...
3
votes
1
answer
1k
views
Possible to parse ldapsearch output?
I have an ldapsearch query to pull some data of an email system, I am trying to parse the data into something I can analyze in a table/flat file, and generate reports on the accounts.
Sample of the ...
2
votes
2
answers
363
views
Convert lscpu output to row based format in excel/csv table format
I have the below data (lscpu output) for 1000 servers and I want the same in excel but in row format and not as in command output in columns
1.2.3.4 CHANGED
Architecture: ...
-1
votes
1
answer
272
views
Copy/Move Entire Line To End Of The Line Above
I have a file that looks like the following:
/path/to/a/very/long/path
0 0 0 0 0 0
I need to move the line starting with a number (this can be any value not necessarily 0) to the end of the ...
4
votes
1
answer
3k
views
How to correctly escape single quotes in AWK
It isn't clear exactly what more needs to be escaped in the following macro to allow it to be used with awk or sed on FreeBSD.
define(`RELAY_MAILER_ARGS', `TCP $h 2525')dnl
Here is an awk command ...
0
votes
1
answer
562
views
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)
...
0
votes
0
answers
92
views
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
#...
0
votes
1
answer
217
views
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 ...