0

I've a script like this.

#!/bin/bash
echo -n /tmp/ /other_dir/ | xargs -n 1 -d\  -I % $1 

What I would like to achieve is the possibility of using the delimiter "%" in the command associated to the $1 variable. For example

. myscript "ls -la %*.txt"

which should list only .txt files in each directory. I've tried also without the quotes but it doesn't work. The message I get now is that /tmp/*.txt and /other_dir/*.txt are not existent.

Nik
  • 327
  • 2
  • 10
  • Maybe this will help: https://stackoverflow.com/questions/11087407/xargs-respect-wildcards-in-searches – Ruud Helderman Jun 20 '18 at 10:59
  • 1
    Possible duplicate of [How do I pass a wildcard parameter to a bash file](https://stackoverflow.com/q/19458104/608639), [pass wildcard to command in shell script and store it in a variable](https://stackoverflow.com/q/48339963/608639), [How to access literal wildcard argument before it's expanded to matching files?](https://stackoverflow.com/q/18060389/608639), [Pass wildcard to alias](https://stackoverflow.com/q/5699749/608639), etc. – jww Jun 20 '18 at 13:21
  • This question is really unclear; if the proposed duplicates don't help you, maybe try to rephrase your question to explain in more detail what you hope would happen. – tripleee Jun 21 '18 at 04:13

0 Answers0