Questions tagged [awk]
A pattern-directed scanning and processing language.
8,403 questions
3
votes
4
answers
369
views
reformat data for PCA with AWK
I'm working on wrangling some data into a matrix format for a PCA analysis. I have attempted a more straightforward version with R, but pivot_wider() fails due to the massive size of this dataset (~4....
1
vote
2
answers
135
views
find awk grep - search and replace & passing modified contents to awk to overwrite the existing file
I have a folder with many subfolders full of various Quarto(reg) files & in those files there are links that are located in varying positions in the file lines.
UPDATE ON 3 November 2025 in ...
0
votes
2
answers
90
views
Cleaning-up previous kernel RPMs after reboot
I have a few RHEL 8/9 boxes with a cron job that updates them automatically every week.
The reboots are done manually from time to time and I would like to write a script to simplify the removal of ...
3
votes
5
answers
617
views
awk - print the leading part of a matching pattern with back references
I want to print the part before a matching pattern with awk.
The original problem is, I want to get the service name from kubernetes pod names.
We have pods with names like some-name-and-foo-[[:alnum:]...
14
votes
1
answer
874
views
Does POSIX guarantee that awk programs with only a BEGIN action won't read stdin?
Consider this awk invocation:
awk 'BEGIN {print 1}'
There are no input files, so stdin is used for input. However, the program only contains a BEGIN pattern, so there is no need to read it. Does ...
-1
votes
7
answers
615
views
Insert a character after every 2 character but discard first 2 characters
I want to print a colon after every 2 characters of alphanumeric Value and I found something like below. But I am not sure how to remove initial 2 characters from the output and what is the meaning of ...
4
votes
4
answers
485
views
Remove new lines and everything after comment symbol with awk or sed
How to remove comments and newline symbols without using two pipes.
I have bookmarks.txt file with comments.
https://cookies.com # recipes cookbook
https://magicwands.com # shopping
I can copy link ...
5
votes
5
answers
378
views
Compare files and combine rows with matching values based on last column
I'm working with several files which come in bundle of four, across groups the bundels have the same number of columns; see below for an example showing the first four rows with header:
File1 has ...
-2
votes
1
answer
150
views
sed inplace in selective block
I have a dir containing logstash config files
these files have filter blocks, and sometimes nested child blocks
need to match whole filter block
filter { any text till final matching closing brace for ...
-2
votes
4
answers
202
views
How to strip data from html using awk?
I'd like to retrieve data from here https://www.sbs.com.au/ondemand/tv-series/la-unidad/season-1. I wget the page to file.
The data I seek is in the form of (samples):
https://www.sbs.com.au/ondemand/...
-4
votes
6
answers
250
views
Perl or sed script to remove a specific content of a file from another bigger file
I have a file (FILE1) with some repeated sections as below (example):
LINE 1 ABCD
LINE 2 EFGA
LINE 3 HCJK
REMOVE LINE11
REMOVE LINE12
REMOVE LINE13
LINE 4 ABCDH
LINE 5 EFGAG
LINE 6 HCJKD
REMOVE ...
2
votes
6
answers
679
views
Awk prints only first word on the field column
Please see my linux bash script below. I can't achieve my target output with my current code. It keeps reading the whole column 4.
input_file.txt:
REV NUM |SVN PATH | FILE NAME |DOWNLOAD ...
1
vote
2
answers
129
views
How to extract a sub-heading as string which is above a search for word
I'm new to Bash and I've been self-taught. I think I'm learning well, but I do have staggering gaps in my base knowledge. So sorry if this is woefully simple bbuuuttt...
Essentially, I need to sift ...
0
votes
5
answers
214
views
Rename a set of files according to a specific scheme, with rename back option
In Linux in a directory there are files, ls -1 shows me this output :
file1.1-rvr
file1.2-rvr
file1.3
file1.4-rvr
file1.5
file1.6-rvr
file2.1
file2.2
file3.1
file3.10
file3.2-rvr
file3.3-rvr
file3.4
...
6
votes
7
answers
1k
views
How to find numbers in a textfile that are not divisible by 4096, round them up and write new file?
In Linux there is a file numbers.txt.
It contains a few numbers, all separated with space.
There are numbers like this: 5476089856 71788143 9999744134 114731731 3179237376
In this example only the ...