by dvh · 11y ago · 0 comments
$ basename $PWD
etc
$ echo $PWD | basename
<this prints nothing>
I even reported it decade ago but nobody cares.Summary of that is you can filter using xargs like:
get_file_paths | xargs basename -a
No point having two ways to do something,
especially when there are caveats about enabling stdin processingBecause a lot of people have use for a filter version
> It doesn't act as a filter, processing a stream of data, but rather as a plain function.
That's the problem with a lot commands, some work as filters, some as simple commands, and other do both. The reasoning on the decision is confusing.
[edit: yes, combining with xargs will often work]
$ echo ${PWD##*/}
etc
use your shell to its full power basename `echo $PWD`Can you give an example where I have a file (a.txt) of 100 file names and need the basename of each? I'm pretty sure dvh just used echo to show a simple example, not an actual use.
while read line ; do basename "$line" ; done < a.txt