The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,839 other subscribers

bash script for $* loop accept command line with spaces in wildcard file names at DuckDuckGo

Posted by jpluimers on 2026/05/05

Back when I wanted a more universal solution [Wayback/Archive] bash script for $* loop accept command line with spaces in wildcard file names at DuckDuckGo I got into a mess of tips that either did not work at all, or were very convoluted.

As back then I only needed a one-time solution, I just listed the filenames with ls into a text file, did some sed and editing steps, then had each file execute in a separate step. Low tech, non-repeatable when new files appeared, but good enough.

In case I want to go for a more universal solution, below are some links to investigate further. Will likely take me hours, so most of the time this is not worth it. Maybe the subshell plus $IFS (Input Field Separators) is a good start, though it gives me a feeling that in the future it will break something else that was expecting a default $IFS value, as is using while read loop. Both types of solutions feel too convoluted. Same for the array solution below.

I might have just been spoiled with PowerShell piping objects instead of strings having made life so much easier.

Links:

Queries:

  1. [Wayback/Archive] bash file parameter with spaces at DuckDuckGo
  2. [Wayback/Archive] bash script for $* loop accept command line with spaces in wildcard file names at DuckDuckGo
  3. [Wayback/Archive] bash script accept commandline with spaces in filenames at DuckDuckGo

--jeroen

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.