All Questions
8,400 questions
3
votes
5
answers
495
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
865
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
532
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
459
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
352
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
140
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
176
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
5
answers
226
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
637
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
125
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
210
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 ...
1
vote
2
answers
92
views
Moving from single-purpose awk scripts to flexible function-based processing
A common way awk scripts are written is to use top-level pattern-action blocks.
The file would then consist of multiple top-level pattern-action blocks. Each
block would apply to input lines matching ...
-3
votes
1
answer
81
views
Passing variables to awk without assigning a value
One can pass an AWK variable using the -v option that requires an assignment.
-v variable=value
Is it possible to simply pass
-v dpa
without specifying a value?
3
votes
1
answer
266
views
AWK Syntax Error When Using Pattern-Action Blocks Inside Conditionals
Have written some code in an awk file. Basically the code captures lines starting with ### DK and returns the block between two blank lines. Would like the capability of either using a function or
...