Skip to main content

All Questions

Tagged with
2 votes
2 answers
73 views

Regex using Bash metacharacters in double bracket `[[…]]` command using `=~` operator

The Bash reference manual, in sec. 3.2.5.2 Conditional Constructs, says It is sometimes difficult to specify a regular expression properly without using quotes, or to keep track of the quoting used ...
the_eraser's user avatar
5 votes
7 answers
264 views

gawk hangs when using a regex for RS combined with reading a continuous stream from stdin

I'm streaming data using netcat and piping the output to gawk. Here is an example byte sequence that gawk will receive: =AAAA;=BBBB;;CCCC==DDDD; The data includes nearly any arbitrary characters, but ...
user12280249's user avatar
-1 votes
0 answers
21 views

Extended Regular Expression for email id in bash [duplicate]

While learning about BRE and ERE, I came across this example grep -E "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}" emails.txt emails.txt [email protected] [email protected]....
Arav Stark's user avatar
2 votes
1 answer
73 views

How to use a pattern-list within a longer path name in a cronjob?

Every day I need to move four files from one folder to a subfolder. On May 26th, these are the files from yesterday: changes-ar-240525.txt changes-dp-240525.txt planned-ar-240525.txt planned-dp-240505....
user avatar
0 votes
0 answers
46 views

Confused about why the regex pattern does not works [duplicate]

I'm using npm ls -a which gives the following ouput: └─┬ [email protected] ├── [email protected] └── [email protected] I'm trying to extract all the dependencies and store it in a file with the following ...
UTKARSH TYAGI's user avatar
1 vote
3 answers
46 views

grep expression behaving weird (unix/mac) while reading a conf file

What's going wrong in below grep expression, appreciate any help. $cat foo.txt ## not to be read ; this one too and next one also coz it has sapce first_var= first_val second_var=y second_var=yes Now ...
explorer's user avatar
0 votes
0 answers
35 views

How to use sed in shell script with value containing line break \n? [duplicate]

In my shell script I have conf=2bi5oIl0hldy/p3fe+KMQTVjUSg89ywhdMCaSOAopEVFM\nKlj4RDJcmNcEa1cgxL3sJNBHrw==\n And I have a ini file that has parameter looks like this: ^PASS= SNlfkDahPoWNYCY0V+...
user1508682's user avatar
  • 1,361
0 votes
2 answers
64 views

How to use awk command to print multiple lines based on the matched and filtering condition

I am trying to filter out the logs which are 7 days older than the newest log, for example, if the last section of log is 2024-02-13 then all the logs on 2024-02-05 would be removed. The example log ...
Megan's user avatar
  • 3
0 votes
1 answer
68 views

How to use quotation marks with bash regex? [closed]

I want to use a regex in my Bash script like the code below: REGEX='^\s*-.*|^\s*file:\s*["'\''].*' if [[ ${LINE} =~ ${REGEX}.* ]]; then # TODO fi If I execute this in the script in Windows it ...
floriandev's user avatar
0 votes
3 answers
107 views

Find files matching a regex pattern

How do I find text files (.txt) that starts with the letter "M" in the current directory in bash? I have tried find -E . -type f -regex '^M[^/]*\.txt$' but it doesn't work. Using \./'^M[^/]*...
jus0521's user avatar
  • 23
-1 votes
2 answers
76 views

Extract numbers only part in shell script

I need a help to extract a part of string into a variable with a shell script. $STR=“ttysggjs364-hhe 1738.98” I need 1738.98 in to a variable. How can I do this. Hope you guys can help me. Thanks
kalanamw's user avatar
5 votes
4 answers
351 views

grep command that matches lines with letters in alphabetical order

I need help figuring out a regular expression with grep that will search a file and display lines that put [a-z] in alphabetical order in each 'set' separately (it will become clear with the examples) ...
mister entername's user avatar
0 votes
1 answer
62 views

grep -E (not working) vs grep -Po (working) [duplicate]

I have shell script for ci cd pipeline. I am executing it in intellij ide terminal. latestVersionAvailable=$(curl -s $artifactoryPath/maven-metadata.xml | grep -Po '(?<=<version>)'$VERSION'.*?...
Sri's user avatar
  • 1,227
0 votes
3 answers
81 views

Finding lines where the occurrence of word happens only after a specific searched word

Consider the below set of lines in a file: File1.csv Apple is red WHERE the column ALP_ACCT_PROD_ID, it can be plucked Apple is red ON ALP_ACCT_PROD_ID , WHERE it can be plucked I want to look after ...
Samrat Saha's user avatar
1 vote
2 answers
96 views

Is the use of regex here POSIX compliant and is the code used appropriate for the problem described?

Following from my previous question here, please see below a fuller form of my question. Code use case The current code is a module for use in polybar, a customisable status bar. As per the first link,...
twelfth's user avatar
  • 69

15 30 50 per page
1
2 3 4 5
131