All Questions
98 questions
1
vote
1
answer
96
views
What does "/$" mean to "grep"?
I'm using these two codes below.
ls -lap . | grep -v "/$"
ls -lap . | grep -v "/"
These two give me different outputs in some cases. What does $ mean in that context?
0
votes
1
answer
284
views
using ripgrep with regex including literal dollar symbol
Suppose I have a script containing something like
VAR=${VAR1%.*}
I'm looking for a command along the lines of
rg "${.*%"
to find it, but I can't get anywhere near.
all of these fail
rg &...
0
votes
1
answer
169
views
Whats the meaning of this sed command sed '/^[[:space:]]*$/d'
I came across this sed command in a script to compare a machine's local binaries to GTFObins binaries.
for i in $(curl -s https://gtfobins.github.io/ | html2text | cut -d" " -f1 | sed '/^...
0
votes
2
answers
121
views
Why does bash regex fail for meta characters? [duplicate]
I am trying to do a bash script to check if input file name is of format name.json.
The regx in bash doesn't work but it works with grep.
file t1.sh
echo "$1"
regx="^[\w\d-]+[.]json$&...
-1
votes
2
answers
425
views
How to get complex regex to work in bash
The idea is to get a rudimentary check on input pattern for a url:
$ ns='abc.def.com'
$ reg_expr="\N*\.(\D{2}|\D{3})$"
$ echo $reg_expr
\N*\.(\D{2}|\D{3})$
$ [[ $ns =~ "$reg_expr" ]...
1
vote
2
answers
749
views
How does one use regex to check input between 0-5 in bash
What is the regex pattern for checking for a single digit number within a range?
I am trying the following pattern which seems to work when tested on
https://regex101.com/.
pattern: \b([0-5])\b
...
0
votes
2
answers
688
views
Regular Expression Bracket Expression with bash
I want to write a regular expression that only allows a user to enter an input which contains alphanumeric characters, underscores, periods, dashes, and plus signs.
In a bash script, I have:
VALID=&...
0
votes
1
answer
153
views
Find files (ignoring extension) that may contain spaces, based on a supplied text file containing this list
With my limited knowledge of Linux tools, I hit a wall.
Because my list of files contains spaces (space character), the "find" command fails to find any hits, but does not produce any errors....
0
votes
1
answer
142
views
Output of Command not being stored and failing Regex
I'm trying to write a git post-push hook that runs yarn prettier --check ./src for my react app, to enforce good code format. I thought that I could store the output of the command and use regex to ...
0
votes
1
answer
5k
views
add a new line after a specific string in a file? [duplicate]
Right now I'm using
echo sed '/\Random/a \
newly added line' info.txt
to append some text to a file but I also need to add text below a certain string let's say random, I know it is possible with ...
0
votes
1
answer
2k
views
RegEx to extract file paths from a logfile
I need to get the file paths from a log file. I thought I will try this with regex.
A file path would look like this:
75/751234/751234V0001_test-tag1-tag02-75x75_01.jpg
I'm not a pro in Regex, so I ...
5
votes
6
answers
1k
views
split line according to matching pattern in bash
I have the following situation, with two files.
File 1
not relevant = does not matter
some stuff
# var1=1
# var 2 = 2
# var3 = 3
some stuff
File 2
some other stuff
# does not matter either
# var1=a
# ...
2
votes
1
answer
764
views
SED and REGEX extraction and rejecting if pattern not found
In the SED command, I want to remove everything that comes after 2000_SOMENAME also if possible want to give an error if that format is not found.
For example, if the file name is ...
3
votes
1
answer
782
views
Extracting specific files from a jar using regex
I have a config jar that contains files like below in its resources directory. The names are in the format <text>-<text>.properties or <text>-<text>-<alphanumeric>....
-1
votes
1
answer
40
views
bash + verify if file that ended with many combinations exists [duplicate]
we can have the /tmp/file.1 or /tmp/file.43.434 or /tmp/file-hegfegf , and so on
so how we can verify in bash if any /tmp/file* exists ?
we try as
[[ -f "/tmp/file*" ]] && echo "...