Questions tagged as ['regex']
This question (How to get values after an equal sign) is basically what I want:
Given a line of text, with named parameter looking syntax like color=red
, using bash how can you grab that color value (yielding red
)?
Except in that question, the line of text is entirely those key-value pairs, so the accepted answer utilizes bash's eval
since that syntax happens fit very nicely.
I'm wondering for a gen ...
Taking a self guided linux tutorial and I keep getting hung up on this
My output keeps including the "clock 15" please help
#!/bin/sh
#comment single RegEx to match all of the items that you have enough rupees
sed '1d' hw0207.txt | grep -v [2-9][0-9]
#comment grep will filter all numbers greater than 12, -v represents not
#comment first sed was to remove first line
I'm ...
I have a huge text, and I would like to indent all lines which start with italic text, via find/replace.
I tried using ^ and italic via the format button, but then the search string is not found.
If I fill in ^. and italic (via the format button), then due to the dot it finds the search strings, but then my first letter is disappearing everywhere when I enter \t in the replace box.
So how to deal with ...
New to Linux and the only way I can get this to work is by using the awk command unfortunately the main directions specify to not use awk.
this is what I got
#!/bin/sh
#comment Write a single RegEx to match the lines that access port 22 and only those packets
grep '\s22\s' hw0206.txt | awk {'print $4'}
#comment grep returns the whole line with matched string
#comment \s22\s regular expression to match ...
In this question I understood that we can only refer to captured groups in the rename command using single quotes.
Is there a way to use both captured groups and other variables in the same rename command?
Example:
var="-old_file"
cd /etc
rename 's/(bash\.bashrc)/$1$var/' *
Simple problem but I can't fix it.
I have the following perl regex:
echo ... | grep -P "(?i)(v(ersion)?)\s?(?!0)\d(\.|,)\d{1,}"
This is supposed to match every string that describes a version of something (e.g. V2,0
or version 1.2
). But it doesn't match when the version starts with V0...
. However, when I execute this, I get an error -bash: !0: event not found
because !<string>
is used to search thr ...
Simple problem but really weird.
When I make a curl request and do ... | grep -Po "^\d+$"
, it returns nothing eventhough there are 400+ results that should match. See below:
#example snippet of curl output
107
00:15:54,936 --> 00:15:56,646
Yeah, this is him.
We got him.
108
00:16:07,823 --> 00:16:11,869
So, how long
you been in South Florida?
109
00:16:11,953 --> 00:16:13,871
A while.
Be ...