Skip to main content

All Questions

Tagged with or
Filter by
Sorted by
Tagged with
3 votes
3 answers
901 views

The following script is supposed to check $1 and see if it is a specific value. It only works when one Bash [[... =~ ...]] regex check is passed in an if statement. The error is: When more than one ...
EmberNeurosis's user avatar
0 votes
2 answers
59 views

Logical way would be to use an 's/[\[\]]/_/g' regexp replace, however it does not work as intended to. It replaces a chain of [ and ] with a single _. $ echo 'x[]x'|sed -E -e 's/[\[\]]/_/g' x_x $ echo ...
peterh's user avatar
  • 10.5k
0 votes
2 answers
109 views

I'm trying to understand some subtle behavior of find and its -regex option I am trying to create symbolic links from files entitled slides_.*.pdf in folders that start with L1[0-6]. I tried the ...
mikemtnbikes's user avatar
1 vote
1 answer
44 views

I was looking at logwatch, but found that it appears to have been replaced by logcheck, and that logcheck is configured by default for just two files using various regexs to match lines in those logs. ...
leeand00's user avatar
  • 4,971
3 votes
2 answers
201 views

I'm stuck with this error without clue or reference how to solve it: I have this list on text.txt Angie Apple Angie Banana Angie Tomato Angie Peach Angie Onion I'm running substitution through ssed (...
Zerchro's user avatar
  • 31
6 votes
3 answers
377 views

Can someone explain the issue I've described below, and perhaps suggest a resolution? I'm trying to process a set of filenames using find. My platform is macOS (Ventura 13.7.7), and the shell is zsh ...
Seamus's user avatar
  • 3,896
-1 votes
1 answer
80 views

So, I'm facing a curious issue with sed; I have reduced my problem down to the following. Why does sed -e 's/\"\([^\"]*\)\">/\1/' <<< '["\{">' return ["\{&...
Grass's user avatar
  • 145
-1 votes
3 answers
224 views

Here is a silly example that effectively illustrates what I need: echo '"this text", " ", "is in speech marks"' | perl -lne 'print "$1" if /"(.*?)"/' ...
Signor Pizza's user avatar
2 votes
3 answers
377 views

I need to keep only last 30 days events in the log and remove other data. Log has timestamp (date +%e/%b/%Y:%H:%M) and next line values like 01/Jan/2025:00:00 value1 value2 ... 01/Jan/2025:06:45 ...
Aleksey's user avatar
  • 75
3 votes
2 answers
186 views

The Issue I've been parsing a file with sed trying to tweeze out the desired data. This has worked fine for most lines in the file but there appears to be some embedded special characters that are ...
Gandalf's user avatar
  • 33
0 votes
5 answers
881 views

I have a text file that mixes names and email addresses, in a comma-separated list. First Person <[email protected]>, Second Person <[email protected]>, Third <[email protected]> ...
hugomg's user avatar
  • 6,115
-2 votes
1 answer
150 views

I have a dir containing logstash config files these files have filter blocks, and sometimes nested child blocks need to match whole filter block filter { any text till final matching closing brace for ...
Sollosa's user avatar
  • 2,009
3 votes
6 answers
230 views

I'm trying to clean files that are copy/pasted versions of my Cygwin (mintty) terminal running bash1. Usually, the input and output are separated by a linefeed ('\n'), as expected. However, when I ...
bballdave025's user avatar
8 votes
1 answer
606 views

I'm not talking about -o option. Posix says: The search for a matching sequence starts at the beginning of a string and stops when the first sequence matching the expression is found, where "...
Mark's user avatar
  • 99
-1 votes
3 answers
120 views

I'm trying to use sed to remove links like and leave just the title: ## [Some title](#some-title) This is my command: sed 's/^\(\#*\) *\[\([^\]]*\)\].*/\1 \2/' I expect to have just the text without ...
jcubic's user avatar
  • 10.5k
0 votes
0 answers
57 views

General overview With BorgBackup, I do a backup of my whole $HOME. However, some files (all located on ~/.local/share/) occur a rights error. Probably cause it’s ephemeral files belonging to root, I ...
fauve's user avatar
  • 1,529
1 vote
3 answers
392 views

I tried this sed -i '/^already satisfied$/d' loggocd.txt but lines like this one Requirement already satisfied: cryptography in /home/go/.pyenv/versions/3.9.1/lib/python3.9/site-packages are not ...
MJoao's user avatar
  • 47
-3 votes
2 answers
107 views

For example I have file with many of lines and it has such part ... pattern1 line1 line2 line3 pattern2 ... how can I extract line[1-3] via one-liner command (awk or something like that)?
Aleksey's user avatar
  • 75
2 votes
4 answers
184 views

I have a dataset of images labeled/classified by characteristics, where an image can have more than one label. I want to count how many of each identifier I have. A toy dataset is created below, with ...
bballdave025's user avatar
-1 votes
3 answers
221 views

I have this list: list="aa bb cc dd ee ff ab cd ef" What I'm trying so far: $ grep -o "^[^cd]*" <<<"$list" aa bb Expected output: $ grep -o "^[^cd]*" ...
Zero's user avatar
  • 39
3 votes
3 answers
292 views

I am fairly new to regexes and it appears I am missing something in my understanding. I have the following file, and I am trying to insert a value if it is missing. The file looks like [composefs] ...
adam's user avatar
  • 33
6 votes
1 answer
181 views

I installed sudo v1.9.16p2 on a RHEL 9.5 server which should support regex matching. As a test I created a test user (testuser) and created a (simple?) rule in /etc/sudoers for this test user that ...
Daryel Villavicencio's user avatar
1 vote
2 answers
509 views

Got a makefile whith this command which convert folder names on ./cmd/ from snake_case to PascalCase test: @for f in $(shell ls ./cmd/); do \ echo $${f}; \ echo $${f} | sed -r 's/(^...
Ricardo Albear's user avatar
0 votes
5 answers
130 views

MATCH1.MATCH2 { always same MATCH3 } All three MATCH(es) must match. input: foo.bar { always same bus } 1.2 { always same 3 } a.b { always same c } i.ii { always same iii } b.2 { ...
sloppy's user avatar
  • 171
0 votes
4 answers
127 views

I have a list of celebrities with their place names as, Bill Gates Manhattan Elon Musk California Narendra Modi Delhi Donald Trump Washington I like to rewrite with the location name in the middle ...
Saravana's user avatar
  • 193
1 vote
3 answers
108 views

Can anyone help? I've exhausted my knowledge and troubleshooting skills trying to get this working. Here is the example data from "msg": date=2025-03-26 time=12:45:57 devname="this-is-...
user2008555's user avatar
1 vote
1 answer
308 views

I'm new to sed, I have a string lightdm --session-child 14 21 the two numbers can change and I would remove everything after lightdm I tried various way but none worked sed 's/ --session-child*//' ...
klatls's user avatar
  • 53
0 votes
2 answers
111 views

I have the following directories: 1 12 123 1234567 1234566 1234555 121 I want to rsync the directories with exactly 7 digits in the name. (That would be 1234567, 1234566, and 1234555 from the above ...
Kaleem Khattak's user avatar
6 votes
3 answers
573 views

In Perl, /a/i matches both A and a, so I don't have to write /A|a/. What is the easy way to write /4|4/ ? Yes, I'm talking about $ unicode 4 4|grep U+ U+FF14 FULLWIDTH DIGIT FOUR U+0034 DIGIT FOUR ...
Dan Jacobson's user avatar
-1 votes
1 answer
85 views

Does anyone know how the Unix find search -name queries with _? in leftmost column relate to Kleene Star as defined on Wikipedia? How can I accomplish the rows with _? using find? . : empty ...
notaorb's user avatar
  • 101
0 votes
2 answers
162 views

The problem is as follows (Here I don't use find since it doesn't support double-asterisk wildcard **): $ FILES=(foo/**/*.suffix bar/**/*.suffix2) $ grep baz "${FILES[@]}" # works # I use ...
An5Drama's user avatar
  • 173
2 votes
3 answers
329 views

This highlight feature can be done easily in grep with --color. But grep can't do regular and invert match at the same time, e.g. grep foo -v bar ... (I need this feature since --color can be only ...
An5Drama's user avatar
  • 173
3 votes
1 answer
274 views

I'm standardizing the name of several files at once, so I wrote a regex for perl-rename: perl-rename 'y/A-Z/a-z/; s/ã|á|â/a/g; s/é|ê/e/g; s/í/i/g; s/õ|ó/o/g; s/ú/u/g; s/ç/c/g; s/(?<=\d-)*\s/_/g; s/...
Alex Braga's user avatar
0 votes
3 answers
1k views

i have this string grafana-stack_alloy and require everything after the first underscore alloy. I need the result as a group $1. Tried this one, but it failed. (?:)?([^_]+)*$. Can anyone help me to ...
user2931829's user avatar
1 vote
4 answers
252 views

I'm trying to use Vim to find, via /, lines that start and end in specific ways. In particular, I'd be looking for lines that start with the character > and without the string RNA at the very end. ...
Mark Pauley's user avatar
2 votes
3 answers
117 views

I have a pretty basic text file on a Linux machine that has stuff like Chapters, Dialogues and References. This is what it looks like Chapter: 1 One: Birds and Trees Birds are beautiful and trees ...
learningregularexpressions's user avatar
8 votes
2 answers
1k views

The only file in my current working directory is called test.txt and its content is simply: This is a little test file. Executing grep -in * -e 'te.?t file' gives no match. But escaping ? works: grep ...
Dominic van der Zypen's user avatar
0 votes
2 answers
165 views

No matter what I try with cut, awk, sed, or grep, it orders by ID first only then last name then first name when it should go in order of last name so it instead should look like f132b02: Kiara ...
Natasha Shorrock's user avatar
0 votes
2 answers
67 views

I am trying to use grep to match only a specific part of a row in a file. The file is a huge csv file with some columns containing json with commas so it is hard to figure out which column what I am ...
smith's user avatar
  • 181
0 votes
2 answers
263 views

I posted a question about detect consecutive lines in a text, with the same words and the same order, the amount of spaces at leading, trailing, or between words may vary from one line to the other. ...
Sistemas Libsur's user avatar
0 votes
4 answers
257 views

I want to find a regex or perl oneliner to detect two consecutive lines that have the same words in the same order, but the leading spaces, trailing spaces and amount of spaces between the words may ...
Sistemas Libsur's user avatar
4 votes
4 answers
428 views

I'm wanting to non-recursively delete all files in a directory where each filename contains only numbers, using only a single line of BASH. I somehow accidentally ran a shell script with commented out ...
Stev's user avatar
  • 61
1 vote
2 answers
759 views

I am using Alacritty terminal for quite some time and it has a great feature to follow hyperlinks when clicking Ctrl+Shift+U. I am using MAC so a default program is open. Iam trying to add one more ...
user2156115's user avatar
0 votes
1 answer
137 views

I'm trying to filter IP addresses from the ip a command via sed. When I write inet6* it works. When I write inet6? it doesn't find the match. With *: $ ip a | sed -ne 's,^ *inet6* \([^ /]*\).*$,\1,p' ...
Irina's user avatar
  • 131
1 vote
1 answer
198 views

Today I have read two answers about which regular expressions are supported by less: Where is less search pattern reference? Kusalananda mentioned re_format(7) and referenced its manpage as man 7 ...
jsx97's user avatar
  • 1,387
3 votes
2 answers
416 views

Is there any concise zsh regular expression parameter expansion to replace the last match of a pattern? I know a very ugly way of doing it, but I'd prefer a cleaner, more concise syntax: # param, ...
XDR's user avatar
  • 471
0 votes
4 answers
153 views

i want to grep for lines containing a OR lines not containing l example text file: ant beetle cow deer eel flamingo giraffe desired output: ant cow deer flamingo giraffe it would be nice to use ...
leetbacoon's user avatar
3 votes
7 answers
651 views

So since GitHub removed the insights tab for non-premium accounts, I'm trying to locally list insertions and deletions to my git repository per day. I figured out this way of printing what I want: git ...
Mister Smith's user avatar
-1 votes
1 answer
44 views

I'm working on a utility that needs to find specific files in an environment. I have a filename that I need to determine the location of, however this filename can exist in several different ...
MKUltra's user avatar
  • 109
1 vote
3 answers
166 views

I have a following file: <head> <title>this is a title</title> <style> here goes a style sheet </style> </head> I need to strip the <title> element ...
jsx97's user avatar
  • 1,387

1
2 3 4 5
57