News for hackers. Stuff that matters.
Re:Four features that justify a new Unix shell by high_priest on Friday October 23, 2020 @09:51PM (#24876267)
Why am I not surprised that the PERL part could be solved with bash in the same space. Why are you so eager to use lang on top of lang, in such simple cases?
Re:Four features that justify a new Unix shell by esaym on Friday October 23, 2020 @10:07PM (#24876331)
Feel free to demonstrate. Take a long path with nasty characters and give me the ending file name. I want "track1.mp3" returned from:

  /podcast/with/nasty'--c h a r$/and/stuff/track1.mp3
Re:Four features that justify a new Unix shell by zimpenfish on Friday October 23, 2020 @10:38PM (#24876493)
If you have that in a variable, which you presumably would if you're reading them one at a time, you can use "remove longest matching prefix" substitution.

    $ i="/podcast/with/nasty'--c h a r$/and/stuff/track1.mp3"
    $ echo "${i##*/}"
    track1.mp3
[Edit: 'thezilch beat me too it by a couple of minutes]
Re:Four features that justify a new Unix shell by sergeykish on Saturday October 24, 2020 @08:22AM (#24878727)
This part is really cryptic, I would prefer

    $ function remove_longest_matching_prefix () { echo "${1##$2}"; }
    $ remove_longest_matching_prefix "$i" '*/'
    track1.mp3
awk -F/ accepts stream as in perl example
Re:Four features that justify a new Unix shell by Jare on Saturday October 24, 2020 @06:46AM (#24878315)
You still get +1 for providing a pointer to the explanation while remaining clear and succinct.
Re:Four features that justify a new Unix shell by AareyBaba on Friday October 23, 2020 @10:28PM (#24876436)
$ basename "/podcast/with/nasty'--c h a r$/and/stuff/track1.mp3"

track1.mp3

Re:Four features that justify a new Unix shell by thezilch on Friday October 23, 2020 @10:34PM (#24876470)

  $ path="/podcast/with/nasty'--c h a r$/and/stuff/track1.mp3"
  $ echo "${path##*/}"
  track1.mp3
  $ basename "${path}"
  track1.mp3
  $ echo "${path}" | awk -F/ '{print $NF}'
  track1.mp3
Re:Four features that justify a new Unix shell by ubercow13 on Saturday October 24, 2020 @08:08AM (#24878675)
In zsh it would be

    echo “${uglypath:t}”