Skip to main content
Be posix compliant
Source Link
Thor
  • 17.5k
  • 3
  • 55
  • 71

You can use xargs or GNU parallel:

echo /path/to/Files/F{1..20} | tr ' ' '\n' |
  xargs -lL conv.sh

or:

echo /path/to/Files/F{1..20} | tr ' ' '\n' |
  parallel conv.sh

Edit - handle space sensibly

As noted by Ole, none of the above methods handle space properly, i.e. dir name would be considered as two separate arguments, the same problem occurs if the directory name contains newlines.

The best way to handle these issues is to use null as delimiter, e.g. with GNU find:

find /path/to/Files -mindepth 1 -maxdepth 1 -type d -regex '.*/F[0-9]*' -print0 |
  parallel -0 conv.sh

You can use xargs or GNU parallel:

echo /path/to/Files/F{1..20} | tr ' ' '\n' |
  xargs -l conv.sh

or:

echo /path/to/Files/F{1..20} | tr ' ' '\n' |
  parallel conv.sh

Edit - handle space sensibly

As noted by Ole, none of the above methods handle space properly, i.e. dir name would be considered as two separate arguments, the same problem occurs if the directory name contains newlines.

The best way to handle these issues is to use null as delimiter, e.g. with GNU find:

find /path/to/Files -mindepth 1 -maxdepth 1 -type d -regex '.*/F[0-9]*' -print0 |
  parallel -0 conv.sh

You can use xargs or GNU parallel:

echo /path/to/Files/F{1..20} | tr ' ' '\n' |
  xargs -L conv.sh

or:

echo /path/to/Files/F{1..20} | tr ' ' '\n' |
  parallel conv.sh

Edit - handle space sensibly

As noted by Ole, none of the above methods handle space properly, i.e. dir name would be considered as two separate arguments, the same problem occurs if the directory name contains newlines.

The best way to handle these issues is to use null as delimiter, e.g. with GNU find:

find /path/to/Files -mindepth 1 -maxdepth 1 -type d -regex '.*/F[0-9]*' -print0 |
  parallel -0 conv.sh
edited body
Source Link
Thor
  • 17.5k
  • 3
  • 55
  • 71

You can use xargs or GNU parallel:

echo /path/to/Files/F{1..20} | tr ' ' '\n' |
  xargs -l conv.sh

or:

echo /path/to/Files/F{1..20} | tr ' ' '\n' |
  parallel conv.sh

Edit - handle space sensibly

As noted by Ole, none of the above methods handle space properly, i.e. dir name would be considered as two separate arguments, the same problem existsoccurs if the directory name contains newlines.

The best way to handle these issues is to use null as delimiter, e.g. with GNU find:

find /path/to/Files -mindepth 1 -maxdepth 1 -type d -regex '.*/F[0-9]*' -print0 |
  parallel -0 conv.sh

You can use xargs or GNU parallel:

echo /path/to/Files/F{1..20} | tr ' ' '\n' |
  xargs -l conv.sh

or:

echo /path/to/Files/F{1..20} | tr ' ' '\n' |
  parallel conv.sh

Edit - handle space sensibly

As noted by Ole, none of the above methods handle space properly, i.e. dir name would be considered as two separate arguments, the same problem exists if the directory name contains newlines.

The best way to handle these issues is to use null as delimiter, e.g. with GNU find:

find /path/to/Files -mindepth 1 -maxdepth 1 -type d -regex '.*/F[0-9]*' -print0 |
  parallel -0 conv.sh

You can use xargs or GNU parallel:

echo /path/to/Files/F{1..20} | tr ' ' '\n' |
  xargs -l conv.sh

or:

echo /path/to/Files/F{1..20} | tr ' ' '\n' |
  parallel conv.sh

Edit - handle space sensibly

As noted by Ole, none of the above methods handle space properly, i.e. dir name would be considered as two separate arguments, the same problem occurs if the directory name contains newlines.

The best way to handle these issues is to use null as delimiter, e.g. with GNU find:

find /path/to/Files -mindepth 1 -maxdepth 1 -type d -regex '.*/F[0-9]*' -print0 |
  parallel -0 conv.sh
Added a space friendly alternative
Source Link
Thor
  • 17.5k
  • 3
  • 55
  • 71

You can use xargs or GNU parallel:

echo /path/to/Files/F{1..20} | tr ' ' '\n' |
  xargs -l conv.sh

or:

echo /path/to/Files/F{1..20} | tr ' ' '\n' |
  parallel conv.sh

Edit - handle space sensibly

As noted by Ole, none of the above methods handle space properly, i.e. dir name would be considered as two separate arguments, the same problem exists if the directory name contains newlines.

The best way to handle these issues is to use null as delimiter, e.g. with GNU find:

find /path/to/Files -mindepth 1 -maxdepth 1 -type d -regex '.*/F[0-9]*' -print0 |
  parallel -0 conv.sh

You can use xargs or GNU parallel:

echo /path/to/Files/F{1..20} | tr ' ' '\n' |
  xargs -l conv.sh

or:

echo /path/to/Files/F{1..20} | tr ' ' '\n' |
  parallel conv.sh

You can use xargs or GNU parallel:

echo /path/to/Files/F{1..20} | tr ' ' '\n' |
  xargs -l conv.sh

or:

echo /path/to/Files/F{1..20} | tr ' ' '\n' |
  parallel conv.sh

Edit - handle space sensibly

As noted by Ole, none of the above methods handle space properly, i.e. dir name would be considered as two separate arguments, the same problem exists if the directory name contains newlines.

The best way to handle these issues is to use null as delimiter, e.g. with GNU find:

find /path/to/Files -mindepth 1 -maxdepth 1 -type d -regex '.*/F[0-9]*' -print0 |
  parallel -0 conv.sh
Source Link
Thor
  • 17.5k
  • 3
  • 55
  • 71
Loading