0

I'm trying to create a alias combining ls | grep | and xargs xdg-open.

This is what I've tried so far. Not sure why it is not working.

alias lso='ls | grep "$1" | xargs -I {} xdg-open {}'
alias lso='ls | grep "$@" | xargs -I {} xdg-open {}'
alias lso='ls | grep | xargs -I {} xdg-open {}'

The idea is be able to to this in the terminal:

$ lso example

The interesting thing is that I can use this using the terminal:

$ ls | grep example | xargs -I {} xdg-open {}'

Does anyone have any work around that?

muru
  • 197,895
  • 55
  • 485
  • 740
  • if you need to take arguments, you need a function, not an alias. aliases literally do text substitution, nothing fancier. The only way this would work is if your arguments can go at the end of the line – Esther Aug 17 '23 at 18:14

0 Answers0