Skip to main content

New answers tagged

4 votes

Syntax Error on ssed for Regex Subroutine definitions

tl;dr: Forget about ssed. Use perl. Here's why: ssed is abandonware. It was last updated in Oct 2005. Its home page on sourceforge is gone (and I can't find any replacement on github or gitlab). ...
cas's user avatar
  • 84k
0 votes

How to specify [[hints.enabled]] Alacritty section one matching hypelinks (open on mac) and second any file paths and open in vim

(Edit: Linux related, not using Mac's open) Alacritty spawns a daemon to run the command in, that's why it's separate from your shell process. Pasting the matched text in your shell could be a feature ...
ocaly's user avatar
  • 1
5 votes
Accepted

Help w/ "posix-extended" regex for 'find'

If you have zsh, you don't need find (and BTW, FreeBSD's find is not old, it's just a different implementation from the GNU one, where extended regexps is just with -E like in grep or sed). find . -...
Stéphane Chazelas's user avatar
5 votes

Help w/ "posix-extended" regex for 'find'

In addition to @muru's answer pointing out that find doesn't support \s (so you need to use [:space:] instead): Instead of A-Za-z, you can use the posix character class [:alpha:], and instead of A-Za-...
cas's user avatar
  • 84k
3 votes

Help w/ "posix-extended" regex for 'find'

Two things: \s is not supported by GNU find. There are \w and \W for word and non-word, but no \s. See the documentation. Also: Why does my regular expression work in X but not in Y? on why the ...
muru's user avatar
  • 77.9k
0 votes
Accepted

Open specific URLs in certain app?

Use a wrapper script: #!/usr/bin/bash url=$1 if [[ $url == *youtube.com/watch* ]] || [[ $url == *youtu.be* ]] || [[ $url == *vimeo.com* ]] || [[ $url == *instagram.com* ]] || [[ $url == *...
Geremia's user avatar
  • 1,250
1 vote

Perl RegEx one-liner that outputs all matches from one line of STDIN

python would be much too verbose as a CLI one-liner For what it is worth, seeing the complex:er perl in @Stéphane's answer... # copy & paste the following lines into a shell to try it out echo '&...
Hannu's user avatar
  • 524
5 votes
Accepted

sed: why my regex does not work correctly

[^\"] means “any character except \ and "”; so nothing ends up replaced. You’ll get the result you’re after if you remove the backslash from the bracket expression: sed -e 's/\"\([^&...
Stephen Kitt's user avatar
5 votes
Accepted

Perl RegEx one-liner that outputs all matches from one line of STDIN

echo '"this text", " ", "is in speech marks"' | perl -lne 'print for /"(.*?)"/g' Or: echo '"this text", " ", "is in speech marks&...
Stéphane Chazelas's user avatar
1 vote

Extract email addresses from line, with multiple email addresses per line

Using any awk, assuming the input is as simple/regular as in the provided example: $ awk -F'[<>]' -v OFS=', ' '{for (i=2; i<=NF; i+=2) printf "%s%s", $i, (i<(NF-1) ? OFS : ORS)}' ...
Ed Morton's user avatar
  • 35.8k
0 votes

sed: invalid usage of line address 0

The line address 0 is a non-standard extension of the GNU implementation of sed that allows doing things like 0,/pattern/ x to run the x action on lines from the start of the input(s) (or start of the ...
Stéphane Chazelas's user avatar
1 vote

sed: invalid usage of line address 0

This will robustly do what I think you want, using any awk: awk -v d="$(date '+%d/%b/%Y' --date='30 days ago')" ' f || ($0 ~ "^"d":([0-1][0-9]|2[0-3]):[0-5][0-9]$") { ...
Ed Morton's user avatar
  • 35.8k
0 votes

How to make Perl half/full width-insensitive regular expressions?

What is the easy way to write /4|4/ ? Here's a long one-liner: perl -COA -lwe "@c=('A'..'C','x'..'z','0'..'9'); $rs = sprintf'[%s%s]', join('',@c), join('',map chr 0xfee0+ord, @c); print $rs; $r ...
Lumi's user avatar
  • 864

Top 50 recent answers are included