I'd like to find all of the files in my home folder on Linux (Ubuntu, in this case) that contain a match a particular regular expression. Is there a simple Unix command that I can use in order to do this?
For example, I'd like to find all of the files in my home folder that contain a match of the following regex (here, using Javascript-style notation): ((R|r)eading(T|t)est(D|d)ata)
I'm trying to use find with the regex option. However my regular expression only captures the basename of the file. Is there a reference to the "directory find is currently in" I can use in my regular expression so that I don't have to account for it by means of a leading .*?
Hi,
what ?* means in sh script?
I know that ? is equivalent to at least one appearance of a preceding expression and * is equivalent to at least one appearance of preceding expression but I have difficulties with a way in which I should interpret following pattern:
-?*
I would expect that it should match expressions like -, --, --- because I read it as follows:
-?
Hi Everybody!
I need some help with a regular expression in Perl that will match files named messages, but also files named message.1, message.2 and so on.
my target is to match exactly IP address with three octes , while the four IP octet must be valid octet - between <0 to 255>
For example I have the following IP's in file
$ more file
192.9.200.10
192.9.200.100
192.9.200.1555
192.9.200.1
192.9.200.aaa
192.9.200.@
192.9.200.:
192.9.200
192.9.200.
I need to match the first three octets - 192.9.200 while four octet must be valid ( 0-255)
I have a Bash script which installs a customised JBoss. The name of the JBoss instance is checked against a regular expression to make sure that the name is valid:
if [[ ! $1 =~ $instanceNameRegex ]]; then
exit 1
fi
We now have a requirement for a second valid regex. ie the name must match either $instanceNameRegex or $secondInstanceNameRegex.
How do I achieve this in the if test?
Using grep (or some other utility), is it possible to find all matches of a regular expression in a folder (searching the text of each file?) I want to find every match of the regular expression zenity within a specific folder, so that I can find the file that contains the string zenity.
After some quick searching and not finding the answer, I decided to write this up for my own reference.My original inquiry was how do I form a double-bracketed if branch statement, using "=~" to check a variable against a regular expression for upper OR lower case of a specific search string in bash. After some working it out, I think I got it.
To match a word one can use
\v(\w+)
From the vim help :h \w:
\w word character: [0-9A-Za-z_]
This works exactly as described in the manual. However, I want to
match words that contain characters beyond a-z, e.g.
prästgården.