All Questions
75 questions
0
votes
4
answers
172
views
bash - slice quoted substrings delimited by spaces into array
following example:
string=" 'f o o' 'f oo' 'fo o' "
array=($string)
echo "${array[0]}"
outputs:
'f
while the expected output is:
'f o o'
The only solution I came with is by ...
0
votes
1
answer
186
views
Grep: Throw if found and show output
I'm struggling getting these two to work together:
Exit with error code 1 if grep finds.
Show either the whole output or the line where it matched.
Right now I have the first, if grep matches, it ...
0
votes
3
answers
687
views
compare multiple files in bash script
bash and shell programming is new for me.I have a few files with the extension .v.gz, in the bash command I am performing some operations, and ill store the result in the same filename with
.txt ...
0
votes
1
answer
599
views
regular expression - command not found on terminal
I am trying to grab my_name 369 from file.txt
I input this grep line with regex but it return an error. I have tried using egrep and it did not work.
Input:
my_name 369 == match
my_name 161 == match
...
0
votes
1
answer
82
views
Validating only four digits using SED
In the SED command, I only want the SED to work if there are SOMETHING_4DigitsHereOnly_SOMETHING2.
For example, if the file name is ITALY_2022_BEST1FRIENDS2_ROME.txt . I only want 2022_BEST1FRIENDS2 ...
1
vote
2
answers
484
views
Print output of httpie command, then pipe to grep
how can I print output of httpie request then pipe to grep to check if request has succeeded or failed?
http --print=hb POST http://localhost:8080 | grep -c "HTTP/1.1 200" && echo &...
0
votes
1
answer
382
views
Count the number of words ends with specific character using Bash
Heys guys I wanted to count the number of words that end with 's' from this URL,
https://matt.might.net/articles/what-cs-majors-should-know/
Here's what I did
curl https://matt.might.net/articles/what-...
1
vote
1
answer
293
views
Pipefail prevents command substituation from evaluating pgrep?
My goal is to run a pgrep lftp -c command inside a shell script to check if lftp is already running.
But the following script never goes beyond "test" output.
Only if I remove the pipefail ...
6
votes
1
answer
14k
views
Grep a list of strings [closed]
I have a multiple strings that I want to find them in a list of files that are in a same folder. So, I want to put all the strings in a sort of list and then apply the command: grep -l string *,so I ...
6
votes
2
answers
1k
views
what is the use of egrep [[:print:]] command in bash?
I am working on an enhancement of a shell script which reads a file and processes it. Basically the input file contains a header record followed by number of detail records. I want to get only the ...
0
votes
2
answers
248
views
Check for line in text bash
This is a really stupid question but I can't find an answer anywhere. So I have a command that prints out lines of text like this:
htop
kvantum
alacritty
And I need to check for a line, not a ...
0
votes
3
answers
866
views
Combine multiple awk functions
I'm very new to awk, I'm trying to do the following in an environment that doesn't support grep -P and doesn't have Perl installed either.
Given I have a list of env variables starting with a prefix, ...
-1
votes
2
answers
138
views
Get number string as output from a paragraph string
I have a output stored in a variable that comes from a .jar script
Token is: XYZ123
Not found in page: 0
Not found in page: 1
Not found in page: 2
Found with ID : #14214733
Now I want to extract the ...
1
vote
4
answers
1k
views
Grep number behind path, tab and space in a string
Given a string s
s="B /home/BL/004_010_0100.0 23 0.031"
How can I grep only the number behind the path, tab and space in a string?
In the string s above, I'd like to extract the ...
2
votes
2
answers
614
views
Print content between first matching brackets
Input example:
START{
some text
{
more text}
almost there
}
nothing important{
...
Desired output:
START{
some text
{
more text}
almost there
}
First open bracket could ...