All Questions
8,383 questions
1
vote
3
answers
64
views
edit all the values in a specific column based on row numbers range
I have a PDB file (coordinates of atoms in a protein) on a Linux machine:
ATOM 1 N GLY A 1 0.535 51.766 5.682 1.00 0.00
ATOM 2 CA GLY A 1 -0.712 50....
4
votes
5
answers
467
views
Remove the first field (and leading spaces) with a single AWK
Consider this input and output:
foo bar baz
bar baz
How do you achieve with a single AWK? Please explain your approach too.
These are a couple tries:
$ awk '{ $1 = ""; print(substr($0, 2)) ...
2
votes
3
answers
254
views
Replacing a string in a file with GAWK issue
I have a program that will run a set of commands against new server installs and I need to change an entry in a file for each install. We need to change the default DNS from 127.0.0.X (which it ...
1
vote
1
answer
64
views
Why can't I run an interactive command in awk in a pipeline?
Consider the following commands:
$ awk 'BEGIN { system("ed") }'
q
$ echo hello | awk 'BEGIN { system("ed") }'
?
$
In the first case, I was able run ed and then stay in the editor ...
1
vote
2
answers
86
views
Filter for arbitrary AND patterns [duplicate]
Consider a command which takes arguments like this: cmd foo bar baz [arbitrary args...]. How do you build a filter of AND patterns based on those arguments?
Something like this pipeline of greps:
grep ...
4
votes
3
answers
220
views
Add columns from variable number of files to base file
I'm dealing with a series of bed files, which look like this:
chr1 100 110 0.5
chr1 150 175 0.2
chr1 200 300 1.5
With the columns being chromosome, start, end, score. I have multiple different files ...
3
votes
3
answers
492
views
How to generate two output files from if/else statement by using awk?
From the info below:
$ cat access.dat
2025/01/01T10:00:01 "GET" /path/resource/api1 User1 500
2025/01/01T10:00:01 "DELETE" /path/resource/api1 User1 503
2025/01/01T04:00:01 "...
5
votes
5
answers
467
views
Unix shell scripting help- how to replace file delimiter if exist inside double quotes data of a delimited csv file?
My input file data:
"Per Sara Porras.|, LLC"|column2_data|column3_data
column1_data|"column2|data"|"column3|data"
Required output:
"Per Sara Porras.@@@, LLC"|...
7
votes
10
answers
2k
views
awk - how to print all fields after $5?
I have an output similar to
975 Jan/21 - 19:59:36 ### sed "/^#include_dir/a include_dir = 'conf.d'" /opt/db/data/efa_bauen_ni_14/postgresql.conf
986 Jan/21 - 20:04:21 ### grep -l "...
0
votes
5
answers
129
views
How to select string delimited by two differnt string pattern
I am having an output similar to the file (filename whatever.com) below...
[...]~ # tmsh list sys file ssl-cert whatever.com_2024
sys file ssl-cert whatever.com_2024 {
certificate-key-size 2048
...
3
votes
2
answers
570
views
How to extract lines by condition from large CSV?
I have a CSV file with 100 million rows, approximately 60GB in size.
Now, I want to create another CSV from it but only take lines that match a certain condition: at the end of the CSV, there is an ...
2
votes
3
answers
225
views
How to highlight the matched regex pattern got by many regex exps disjoined with `||` in awk?
This highlight feature can be done easily in grep with --color. But grep can't do regular and invert match at the same time, e.g. grep foo -v bar ... (I need this feature since --color can be only ...
0
votes
4
answers
280
views
Multiplying a column with a constant after a date in Bash
My file has two columns containing the date and the precipitation in mm for every day.
2024/01/01 5
2024/01/02 0
...
2024/12/26 15
2024/12/27 0
Now I will multiply the second column of the file after ...
0
votes
3
answers
282
views
awk/sed in loop to replace numbers (with result of computation)
I am relatively new to awk and sed.
I have a file with more than 30000 rows/lines; e.g.,
Direct configuration= 5
0.86331344 0.14835363 0.01770155
0.83813858 0.74789354 0.31772038
0.89805721 0....
-5
votes
1
answer
97
views
print two blocks outputs [closed]
I need to print outs of cert file blocks one by one
---BEGIN---
AA
BB
CC
--END CERTIFICATE---
--BEGIN---
AA
BB
CC
--END CERTIFICATE--
would need out put for running in a loop
some thing like
for i in ...