All Questions
112 questions
-2
votes
4
answers
112
views
How to get either a substring or a text value using awk and if?
I can't figure out how to write a simple ping log. I only need either the ms value or the words "no connection".
I have myping=$(ping -c 1 10.0.10.1). I only need the value between "...
0
votes
3
answers
88
views
Need to make multiple multiline replacements in file
I have a file with multiple "paragraphs" like this:
<type>TRANS</type>
<attributes/>
<specification_method>rep_name</specification_method>
<trans_object_id/&...
-3
votes
4
answers
167
views
How to catch all lines of a repeating pattern and do some actions with the subresults
I am looking for a possibility to catch in a repeating text pattern all variable amount of lines between them and then do an action with it in bash.
Example text:
Total:
text1
text2
Total:
text3
Total:...
2
votes
2
answers
334
views
Why does awk concatenate strings from different lines
Good day.
I'm trying to run a ping6 on IPv6 addresses pulled from /etc/resolv.conf.dnsph. It seems though, as if awk is stringing the IPv6 addresses onto one line.
$ grep ^nameserver /etc/resolv.conf....
2
votes
2
answers
139
views
How can I select only successful values from leakcheck output?
I have these results that came from leakcheck. How do I properly exclude "false" results and still include the email using bash
[email protected]
{"success":false,"error":&...
0
votes
3
answers
96
views
grep from a specific value to specific value
For example, I have a file with data:
[2023-03-21 12:27:19 +0000] some_data
[2023-03-21 12:27:19 +0000] some_data
[2023-03-22 12:27:19 +0000] some_data
[2023-03-23 12:27:19 +0000] some_data
[2023-03-...
-1
votes
3
answers
838
views
Searching in a CSV for multiple values and get the associated values from it
I have a file.csv
"ItemNo","Name","Weight"
"a001","Item a","1.1"
"a002","Item x","1.2"
"a003","...
-1
votes
3
answers
584
views
How to match end of last string in file which does not end with punctuation
I'm trying to search a directory for files which do not end in a period. I'm trying to list the file name with the final ascii character which is not followed by period/ punctuation. I've looked all ...
-3
votes
1
answer
42
views
grep/awk/sed lines from match until text
I would like to get the following output from lscpu:
(number of cores) x (cpu model name) @ (max mhz)
I already figured out the attribute I need:
Model name:
Core(s) per socket
CPU max MHz
But on ...
0
votes
4
answers
118
views
Grep line containing a word OR has length in a specific range?
1598427@931
PDD 220624P00051000 ohlc=0,0,0,0 vol=0 oi=424 nbbo=69@2316/113@532 nbbo2=69@145/113@95
PDD 220617C00051000 ohlc=0,0,0,0 vol=0 oi=434 nbbo=530@1921/710@1496 nbbo2=530@31/710@115
PDD ...
5
votes
5
answers
10k
views
Finding the line number of first occurrence of a text in bash script
I need to find out what is the line number of first occurrence of a given search string that should be in the start of a line in a text file and store it in a variable in my bash script. For example I ...
1
vote
2
answers
324
views
Extract field and number of occurrences per line
I have this file:
John Green', 'Age: 32', 'State: New York', 'Total cars: 2', 'Manufacter: General Motor', 'Model: Pontiac', 'Year: 2000', 'Manufacter: Ford Motor', 'Model: Endeavour', 'Year: 2010
...
1
vote
2
answers
2k
views
How to programmatically maintain umask in /etc/profile and /etc/bashrc
I am looking for a way to programmatically maintain a consistent umask in the files /etc/profile and /etc/bashrc. They have an entry such as follows:
if [ $UID -gt 199 ] && [ "`/usr/bin/...
0
votes
1
answer
198
views
How can I use grep, sed, awk, or other Linux tool to search each line of a file for the sequence “\t$month\t$day\n”?
How can I use grep, sed, awk, or other Linux tool or bash script to search each line of a file for the sequence “\t$month\t$day\n”, where…
\t = tab
\n = new line
$month = Sep #$month is a ...
3
votes
1
answer
233
views
How to match two patterns using OR?
I need to use grep and awk in order to match two types of patterns but I cannot figure out the syntax.
My file has values such as:
sample1,gicode1,123,4541,221,3661,Sodalis sp.1
sample2,gicode1,123,...