All Questions
Tagged with quoting regular-expression
52
questions
-1
votes
1
answer
42
views
I can't grep some inputrc string
bind -p |grep -E "\\e.\":" work
but
bind -p |grep -E "\\e\\C-.\":" don't work
I tried a lot of combination
1
vote
1
answer
3k
views
How do I quote square brackets in Ansible variable value for regexp parameter?
I use the ansible.builtin.lineinfile module to modify a PHP-FPM pool configuration file. How should I quote the square brackets (annot.: or other special characters) in a value of a variable for the ...
1
vote
0
answers
101
views
How to move all the files with specific prefix of the directory? [duplicate]
I have a following directory structure (assume no two files have the same name):
Apple1
apple1.jpg
apple2.jpg
Apple2
apple3.jpg
apple4.jpg
Apple3
Tomato
Peach
And i would like to move one ...
0
votes
1
answer
90
views
Putting single quote in the begining of column
I have a .txt file with publications for which columns are separated by a single space.
However, titles also have spaces an in order to separate the columns correctly I need to have all titles in ...
1
vote
1
answer
2k
views
grep: use square brackets to match specific characters
So I am experimenting with the power of grep using this resources
The problem I am currently encountering is that it doesn't seem to work as I intended. so I have an demo.txt file that contains foo....
2
votes
1
answer
180
views
awking for command options from man page
I am trying to auto-generate tab-completions for different commands. I am piping man pages for different commands into awk, then searching for command line options (eg. -shortopt --long-option) ...
5
votes
2
answers
26k
views
How do I grep multiple patterns from a pipe
I want to find three patterns in a list. I tried typing
$ pip3 list | grep -ei foo -ei bar -ei baz
but the shell throws a broken pipe error and a large Traceback.
How do I grep for multiple ...
1
vote
0
answers
2k
views
Why use a variable in a bash regex match inside [[? [duplicate]
There is not a simple answer to this question at this site yet.
This question aims to give a simple and clear answer.
It is usually recommended to use a variable ($regex) in this construct:
if [[ $...
4
votes
3
answers
15k
views
How can search for both single quotes and double quotes in a grep search?
When I do a search bindkey in the zsh plugins directory for key conflicts I get responses from both the .zsh script files and .md files, and some of the zsh readme files use a double quote in the ...
10
votes
3
answers
17k
views
shell test whether multiple lines string contains specified pattern in last line
I want to determine whether a multi-line string ends with a line containing specified pattern.
These code failed, it doesn't match.
s=`echo hello && echo world && echo OK`
[[ "$s" =~ ...
0
votes
1
answer
2k
views
Print a variable in single quote on bash | Weird Variables
On bash script, I need to pass date as ansible extra variable but getting something single quotes related issues;
...
$DT="03-04-17"
ansible-playbook copy2s3.yml --extra-vars 'cdate={{ "$DT" }}'
and ...
0
votes
1
answer
344
views
\1 in sed command not working under xonsh
I don't understand what I'm missing here:
$ echo 'testing' | sed -E 's/([a-z]*)ing/\1ing/g'
ing
I would expect the output to be testing again, since \1 should be test? That input seems to have been ...
0
votes
4
answers
4k
views
Regular expression within single quotes- lose their value? [closed]
The book I am reading - Learning the Bash Shell by O'Reilly specifies some code as follows:
if [ -n "$(echo $1 | grep '^-[0-9][0-9]*$')" ]; then
howmany=$1
shift
....
....
etc
...
1
vote
3
answers
205
views
how to filter inner quotes? [closed]
is it possible to filter, i.e to put ESC in front of the inner quotes with sed, awk or other *NIX tool (no perl/python)?
Example (revised):
$ echo label=\"123 \"456\" 789\" \"AB C\" e f gh | magic-...
9
votes
1
answer
1k
views
Why does `grep fil*` fail?
I found echo file|grep fil* fails, but echo abcd|grep abc* succeeds.
I don't understand it, can someone explain?