Regular expressions are a means of matching a pattern of characters within a string.
1
vote
1answer
24 views
How to Replace Path in Search field using VIM
I'm trying to replace this text in VIM
Actual Path /home/omipenguin/Servers\ Information/systemscript.sh/sysinfo.txt
with this new path
/home/sysinfo
I tried
%s/\/home\/omipenguin\/Servers\ ...
5
votes
2answers
64 views
Lowercase all but the first (Uppercase) letter from UPPERCASE in cyrillic
To make all letters a lower case except the first letter. The first letter would look like "Uppercase" after I changed (from UPPERCASE in cyrillic). The rest (not UPPERCASED) leave unchanged.
I'm ...
8
votes
2answers
222 views
Regular expression in bash script
This is my first time bash scripting so I'm probably making an easy mistake.
Basically, I'm trying to write a script that gets the groups of a user, and if they are in a certain group, it will log ...
3
votes
3answers
55 views
Using a perl compatible regex with GNU grep -P
I'm using this regex (?<=\[')[^,]* on a file containing the following line disk = ['OVS/sdasd/asdasd/asdasd/something.img, w']
I want that to return OVS/sdasd/asdasd/asdasd/something.img
How do I ...
1
vote
1answer
36 views
Brace expression does not work in find regex
I have two folders, CA01 and CA02 under current folder, foo:
foo -+
|
+-CA01
|
+-CA02
When I type
find . -regex ".*CA[0-9]+" -exec echo {} +
Or
find . -regex ...
1
vote
2answers
42 views
Why `rename` behaves differently whenever I use full path instead current path?
Ok, I'm answering a question where the OP have several repositories in Ubuntu that might be causing a problem installing unrelated software. I recommend disabling the PPA's using a single liner rename ...
3
votes
1answer
67 views
Get all regex matches between two patterns and print them to file
I've got a file with a bunch of long lines. I'd like to grab every group between two patterns and print them to a new file, one match per line. I could manage to do this with Python, but I'd prefer ...
2
votes
1answer
28 views
Regex to find NFS filesystems that aren't being mounted with nosuid, except for ones with special needs
I have a script that runs the command mount -v 2>/some/file, which I then parse with another script using the following regex:
^.*[\ \t]+type[\ \t]+nfs(?![\ \t]+.*\b(?:nosuid|nosetuid)\b).*
The ...
0
votes
2answers
48 views
grep + operator
According to the grep manual:
* The preceding item will be matched zero or more times.
+ The preceding item will be matched one or more times.
Let's test it
echo 'agb' | grep 'a.*b' # returns ...
4
votes
2answers
79 views
VIM substitute occurrences of pattern after a particular word in a line
I have such lines in my text.
text before pattern = garbage** text after pattern is pattern
If in VIM I do %s/pattern/saturn/ it replaces all occurrences of pattern. But I only want to replace ...
2
votes
4answers
58 views
Alternative regex for {}
I am trying to replace all of this line, but the numbers:
looktype="123"
so only the numbers show up.
Is this possible in any easy way?
{sub ("look type=\"[0-9]{0,3}", "TEST")}
I am trying this ...
1
vote
1answer
32 views
How to match a literal '*' with sed?
I have this line in my file called test.php
'dbs_password' => 'a8b*cyP0',
and want to replace into:
'dbs_password' => 'password-here',
So I use this sed command with syntax:
$ sed -e ...
1
vote
2answers
46 views
Pattern repetition and regexp
Take the pattern
[UGLER]*
Can the string UUG match against it? I mean to say, is repetition allowed?
2
votes
2answers
89 views
regular expressions with grep
I have this command right here:
grep -B10 -A10 '14:14:50 {"channels":["/alerts/6979/new"],"data":"New alerts for unit 6979"}' mygateway.log
Rather than searching for 14:14:50 I would like the 50 to ...
1
vote
3answers
47 views
Stuck in separating chars into strings in my approach. Found a working approach but can not understand it
I am trying to figure out how to break a string to be on character per line.
I.e ahebhaaa to be:
a
h
e
b
h
a
a
a
I tried:
$ echo ahebhaaa | sed 's/\(.\)\(.\)/\1\n\2/g'
I.e. my ...