34,402 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
7
votes
2
answers
151
views
Ansible way to convert stdout lines to a dictionary keeping multilines under the same key
Given the following text:
Param1 : Value1
Param2 : Value2
Param3 : Value3a
: Value3b
: Value3c
Param4 : Value4
I would like to obtain the following Ansible result dict of strings or ...
CDuv's user avatar
- 2,360
1
vote
2
answers
114
views
awk to get certain next lines when a pattern is matched
I have an input as the following.
0:4:1 untagged 192.168.20.11 255.255.255.0 0.0.0.0 0 0.0.0.0 3205
- 10 192.168.10.11 255.255.255.0 0.0.0.0 0 0.0.0.0 3205
- ...
Advice
1
vote
5
replies
47
views
Find IP addresses with awk matching two strings
I'm trying to get all the IP addresses with response 404's from our Apache web server log file.
This is what I have:
awk '(7ドル == "404") {print 1,ドル5ドル}' /var/log/404.log | sort -n > ip.list
...
Tooling
1
vote
3
replies
77
views
using persistent-memory gawk how variables can created to be local and issolated from other execution instances?
The idea of Persistent-Memory gawk is fabulous because it improves the performance, size, and clarity of many scripts on static and reference data.
However, I have a significant problem in adopting ...
6
votes
4
answers
210
views
awk command to subtract constant from a column and print results
I was working on a one-liner to subtract a constant value (e.g. 100 in this case) from a specific column using awk. So far I can manage to get to where I can print the last iteration only – which ...
6
votes
3
answers
273
views
Does the awk standard unambiguously define that `a || b=c` is (or is not) valid?
Most awk implementations I have tried (gawk, mawk, original-awk, bsd awk) allow the form: a || b = c
The exception seems to be busybox which returns a syntax error unless parentheses are used:
$ ...
jhnc's user avatar
- 18.8k
6
votes
1
answer
142
views
Is there a way to identify if a GNU AWK script is sourced via `-i` / `@include`?
I am looking for a way to write gawk scripts that can function both as standalone tools and function libraries that can be sourced in other scripts.
The difference is in the BEGIN block that I intend ...
3
votes
3
answers
164
views
splitting a FASTA file into a new FASTA file based on the top 100 transcripts
Essentially, I have a large FASTA file with over 100,000 transcripts in it, and I want to take the top 50 longest of those. After doing this:
awk -vRS=">" -vORS="\n" -vFS="\...
1
vote
2
answers
113
views
add special characters "[" in print text using awk
this is a part of my bash script
..
mytstamp=$(date '+%Y-%m-%d %H:%M:%S :: ')
output=$(gawk -v mt="$mytstamp" -f print_errlog.awk errlog.txt)
..
my file: <errlog.txt>
2025年10月11日 14:25:...
4
votes
1
answer
182
views
Does "cmd | getline" have a limit for the passed data?
Stumbled across a certain limit (?) when passing data through "cmd | getline" (with both macOS awk 20200816 and GNU Awk 5.3.1).
Reproducible examples:
file.txt - a text file filled with &...
3
votes
1
answer
173
views
Why is awk not identifying the row of a file which is being extracted using an id from a second file? [closed]
I have a large file with several columns and millions of rows. The first column is a unique id for each record which is a long integer. From this large file I need to create a subset with few thousand ...
-3
votes
1
answer
162
views
How can I dissect a shell 1-liner workflow to understand what this git command does? [closed]
I am updating an existing pipeline on GitLab that creates an automatic cascade on GitLab.
When a merge request is merged, the pipeline is triggered to perform an automatic commit to a lower branch (if ...
1
vote
0
answers
39
views
awk does not print a variable's value [duplicate]
Consider this awk program:
BEGIN {
pat = "<patternprefix> " var "<patternsuffix>"
print ">>> " var
print ">>> ...
4
votes
5
answers
326
views
How to merge two CSV files based on matching values in different columns and keep unmatched rows with placeholders?
I'm working on a data cleaning task and could use some help. I have two CSV files with thousands of rows each:
File A contains product shipment records.
File B contains product descriptions and ...
user avatar
user21677098
4
votes
2
answers
133
views
awk printf long number padding output incorrect
Arch linux 6.15.7-zen1-1-zen,
$ awk -V
GNU Awk 5.3.2, API 4.0, PMA Avon 8-g1, (GNU MPFR 4.2.2, GNU MP 6.3.0)
Start with y.csv:
4 2016201820192020
5 20162018201920202023
5 20162018201920202024
5 ...