Skip to main content

All Questions

1 vote
1 answer
46 views

Search and replace content

PIN A 1 1:3 0:8 0 0:0 PIN B 1 1:0 0 0:0 Z Z:0 PIN C 1 1:3 0:8 0 0:0 Z Z:0 I would like to change the content on PIN A & PIN C only without affecting PIN B to 0 0:3 Z 0:3 Can't seem to find a ...
JSL's user avatar
  • 11
0 votes
4 answers
658 views

Remove hostnames from URL with sed/awk

I got lists of urls with different domains and I want the hostname removed with sed, awk or something similar and only keep the path. There are no urls with port or username@password in it. input: ...
pwrsheller's user avatar
0 votes
1 answer
77 views

How to find the text between the nth occurence of a character and occurence n+1 with perl-rename?

perl-rename 1.14-1 Arch Linux: linux 6.2.12.arch1-1 I have a directory/folder with several subdirectories, all are named by one of the following patterns Status quo of existing patterns something-...
henry's user avatar
  • 914
3 votes
3 answers
207 views

Print a line matching pattern1 unless next line contains pattern2

I want to match lines that have foo unless the next line contains bar. So given a file containing: 1 foo 1 foo 2 baz bar bap only 1 foo 1 would print. I got this to work using a negative lookahead /...
ScottyChi's user avatar
0 votes
2 answers
274 views

perl has problem if filenames contain dashes

... | perl -pe "s/([^$filespec]*)($filespec)/ ... So I have a function where the above construction works fine if $filespec is most things. However if there's a dash in the file name I get an ...
Ray Andrews's user avatar
  • 2,527
9 votes
1 answer
3k views

What are the different versions of the rename command? How do I use the Perl version?

This is a mess. How do I know which command to use when we expect Perl's rename with s/// sed-like syntax, when there're tons of different implementations of rename, that are different versions of the ...
Gilles Quénot's user avatar
1 vote
1 answer
151 views

How can I condense several regex to a one-liner?

I'm having trouble condensing several regex down to an efficient one-liner. I have file names which are named like this: Something (0482) - a123b456 - Something [00xcf bxc v32 Something]. I'd like the ...
telometto's user avatar
  • 2,055
1 vote
3 answers
384 views

Filter git log of pom.xml using regex with grep/perl

I'd like to filter the content of a log of a pom.xml file using a regex. I created it on regexr and it works using PCRE; this is my regex: commit \K[a-z0-9]*(?=[\s\S]*\+.*<version>1.2.0) I then ...
gscaparrotti's user avatar
1 vote
2 answers
231 views

How replace all dots AFTER other chars got captured

I'm trying to rename some shows with the perl-rename command. The format currently looks something like this: series.S01E**.title.of.the.episode.mkv The asterisks are place holders for the episode ...
Zacki's user avatar
  • 17
2 votes
5 answers
348 views

How do I replace all the spaces in just a substring of certain lines in a file?

I have 3000 Markdown files named "journal/*.md", some of which contains file links like this: blah blah text [Label here](file:///path/to file/may contain/spaces) I want to change all such ...
Rich's user avatar
  • 121
3 votes
1 answer
117 views

Best way to remove and replace different characters from multiple filenames?

I have several folders full of files with the following format: Show Name - 07x09 - Episode Title.mp4 What I'm trying to do is rename them to the following format: Show.Name.S07E09.Episode.Title.mp4 ...
user510807's user avatar
0 votes
1 answer
129 views

Retrieving hosts from a URL list using Perl's Regexp::Common::URI::http library

Presently I'm getting a list of URLs from a text file like so: perl -MRegexp::Common=URI -nE 'say $& while /$RE{URI}{HTTP}{-scheme => "https?"}/g' urls.txt And am wondering how to ...
T145's user avatar
  • 213
0 votes
2 answers
451 views

Extract function string before function name with regex

I want a regex that would search for something like: package_name.some_function_name.foo() that would be part of a line and would and extract the some_function_namebut it should be able to work ...
Jim's user avatar
  • 1,421
0 votes
4 answers
1k views

How to extract value between parentheses where before there is a specific string with AWK

Im able to capture all values between parentheses with awk expression 'NR>1{print $1}' RS='(' FS=')' But im struggling to match one in specific, where i do not want to match by line number but by ...
MgtWizards's user avatar
0 votes
1 answer
2k views

Convert this regex to be friendly within sed

I am trying to perform this regex with sed, but seems like sed does not support? It says invalid character range echo "$info" | sed -e 's/(?:\d[\s-.]*){12,19}/*/g' Trying to match any ...
Bao Thai's user avatar
  • 103

15 30 50 per page
1
2 3 4 5
9