[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: sed:awk:perl::rock:paper:chainsaw [was Re: Using .XCompose]



On Sat, Jul 18, 2020 at 3:40 AM Zenaan Harkness wrote:
> # simple version:
> perl -p -i[.bak] -e 's/xxx/yyy/[g];' $(readlink somefile) # readlink is necessary do not clobber symlinks

Speaking as not-an-expert on Raku (née Perl6), you'd write the above
something like:

user@mbook:~$ # One-liner flag set to line-by-line_&_autoprint (-pe)
user@mbook:~$ # "s///" substitute adverb set to global (:g)
user@mbook:~$ echo "aaa xxx ccc" | raku -pe 's:g/xxx/yyy/;'
aaa yyy ccc
user@mbook:~$

On Sat, Jul 18, 2020 at 3:40 AM Zenaan Harkness wrote:
> # hierarchical "find", handle ALL possible interesting filenames, including those that won't display:
> find target/dir -type f -print0 | xargs -0 perl -p -i[.bak] -e 's/xxx/yyy/[g];'
> ```

Again speaking as not-an-expert on Raku (née Perl6), the second half
of the call above doesn't appear too different from your first
example. However, if you want to try your hand at matching a filename
pattern in a directory, you can try the Raku script posted at:

https://examples.p6c.dev/categories/cookbook/09directories/09-06-filenames-matching-pattern.html
https://github.com/Raku/examples/blob/master/categories/cookbook/09directories/09-06-filenames-matching-pattern.p6

YMMV.

HTH, Bill.


Reply to: