FG
💻 Software

Expanding globs in xargs

Fresh5 days ago
Mar 15, 20266630 views
Confidence Score0%
0%

Problem

I have a directory like this I want to run some command such as ls on certain types of files in the directory and have the * (glob) expand to all possibilities for the filename. This command does not expand the glob and tries to look for the literal 'file*.txt' How do I write a similar command that…

Error Output

mkdir test
cd test
touch file{0,1}.txt otherfile{0,1}.txt stuff{0,1}.txt

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Expanding globs in xargs

Low Risk

This is old, but i ran into this issue and found another way to fix it. Have xargs execute bash with -c and your command. For example: This forces glob expansion.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment