Linked Questions

6
votes
1answer
12k views

Interactive less search with wildcards [duplicate]

I'm using less to view a large file and I want to search for a pattern with wildcards — e.g., " x 1??" where ? is any character. Does less support that, and if so how would I do that ...
4
votes
1answer
3k views

Why doesn't the '?' regex character produce a match in sed? [duplicate]

I have a string similar to ../../sdd1 and trying to match sdd from here. I'm trying to use the following sed command: echo "../../sdd1" | sed 's:.*\([a-z]\{3\}\)[0-9]?:\1:' and it does not produce ...
3
votes
2answers
1k views

Why doesn't regex '.+' work as expected? [duplicate]

[root@localhost opt]# cat cfg key = value [root@localhost opt]# grep 'key\s*=\s*.+' cfg [root@localhost opt]# My intent is: the = sign may be followed by zero or more spaces, but must be followed ...
3
votes
3answers
1k views

Not working “+” in grep regex syntax [duplicate]

I'm on Ubuntu 16.04 Trying: grep '.*' file1 Output: file nu-mber o-ne second string Trying: grep '.+' file1 Output is absent Why plus is not working?
1
vote
1answer
5k views

Regex in case statement [duplicate]

I'm having a hard time getting regex matches to work in a bash case statement. Example code: #!/bin/bash str=' word1 word2' echo "With grep:" echo "$str" |grep '^\s*\&...
4
votes
3answers
658 views

Regex not matching file using `find` despite being valid [duplicate]

I am attempting to run this find command to match files with a camelcased name, with the goal being to put a space between adjacent lower and upper case letters, but it's not matching anything: find -...
0
votes
2answers
5k views

Shell pattern matching vs. regular expressions occurence [duplicate]

I am relatively new to Unix, and I stumbled across one curiosity. Some shell constructs like case or find, employ pattern matching, but it is not quite regex. Other commands, like ed, sed, vi, and ...
1
vote
1answer
925 views

Grep options for Regular Expressions. (ERE, BRE, Perl regex) differences [duplicate]

I am getting the hang of grep and regex, but I am confused about the different options. grep --help | grep -i "reg.*ex" -E, --extended-regexp PATTERN is an extended regular expression (ERE) -...
0
votes
1answer
500 views

Why is the regex pattern '?!' not working with grep? [duplicate]

One could use -v to exclude a single word from a file, but I'm wondering why the regex pattern ?! is not working with grep/egrep. I was searching for a pattern to exclude a single word from my search ...
0
votes
1answer
584 views

Can't capture regex group? [duplicate]

I have Bash script below, trying to capture last digits of 'pingnet' but can not get a match. I verified in regex101 and my regex is correct: pingnet="pingcount,site=DC,cur=200 total-up=988" regex='(\...
0
votes
2answers
690 views

Regular expressions in a shell [duplicate]

I have two questions about using regular expressions inside a shell. 1. Use of * According to wikipedia page on regular expressions: *: The asterisk indicates there is zero or more of the ...
0
votes
1answer
802 views

sed with regex not working as expected [duplicate]

This is my first time attempting to use SED. I can get the substitution command to work with simple strings. As in: sed -i 's/foo/bar/g' file.txt However when I attempt to use a Regex it stops ...
0
votes
1answer
719 views

How to make sed regex syntax work as python or javascript? [duplicate]

I have asked a question insert a string to a list variables in text file [use sed] In which @RomanPerekhrest showed me a different regex syntax. \(=([^)]*\)) can capture [^)]* as group 1 . This is ...
0
votes
1answer
451 views

Error using Regex with Unison [duplicate]

Using unison for synchronization on mac, I would like to ignore files such as .DS_store in each directory. In my profile file, I put, as described in section "Ignored path" of the page. ignore = ...
1
vote
1answer
236 views

Grep regex not working [duplicate]

So I'm creating a simple grep command that gets only the last logged in people who's username starts with 161 and has 3 digits next to it: last | grep "^161[0-9]{3}" However it doesn't print ...

15 30 50 per page