Skip to main content
Add missing comma
Source Link
Mikhail T.
  • 864
  • 10
  • 26

Instead of ls */*/*/*/*.jpg, try:

echo */*/*/*/*.jpg | xargs ls 

xargs(1) knows, what the maximum number of arguments is on the system, and will break up its standard input to call the specified command-line multiple times with no more arguments than that limit, whatever it is (you can also set it lower than the OS' maximum using the -n option).

For example, suppose, the limit is 3 arguments and you have five files. In that case xargs will execute ls twice:

  1. ls 1.jpg 2.jpg 3.jpg
  2. ls 4.jpg 5.jpg

Often this is perfectly suitable, but not always -- for example, you can not rely on ls(1) sorting all of the entries for you properly, because each separate ls-invocation will sort only the subset of entries given to it by xargs.

Though you can bump the limit as suggested by others, there will still be a limit -- and some day your JPG-collection will outgrow it again. You should prepare your script(s) to deal with an infinite number...

Instead of ls */*/*/*/*.jpg, try:

echo */*/*/*/*.jpg | xargs ls 

xargs(1) knows, what the maximum number of arguments is on the system and will break up its standard input to call the specified command-line multiple times with no more arguments than that limit, whatever it is (you can also set it lower than the OS' maximum using the -n option).

For example, suppose, the limit is 3 arguments and you have five files. In that case xargs will execute ls twice:

  1. ls 1.jpg 2.jpg 3.jpg
  2. ls 4.jpg 5.jpg

Often this is perfectly suitable, but not always -- for example, you can not rely on ls(1) sorting all of the entries for you properly, because each separate ls-invocation will sort only the subset of entries given to it by xargs.

Though you can bump the limit as suggested by others, there will still be a limit -- and some day your JPG-collection will outgrow it again. You should prepare your script(s) to deal with an infinite number...

Instead of ls */*/*/*/*.jpg, try:

echo */*/*/*/*.jpg | xargs ls 

xargs(1) knows, what the maximum number of arguments is on the system, and will break up its standard input to call the specified command-line multiple times with no more arguments than that limit, whatever it is (you can also set it lower than the OS' maximum using the -n option).

For example, suppose, the limit is 3 arguments and you have five files. In that case xargs will execute ls twice:

  1. ls 1.jpg 2.jpg 3.jpg
  2. ls 4.jpg 5.jpg

Often this is perfectly suitable, but not always -- for example, you can not rely on ls(1) sorting all of the entries for you properly, because each separate ls-invocation will sort only the subset of entries given to it by xargs.

Though you can bump the limit as suggested by others, there will still be a limit -- and some day your JPG-collection will outgrow it again. You should prepare your script(s) to deal with an infinite number...

edited body
Source Link
Mikhail T.
  • 864
  • 10
  • 26

Instead of ls */*/*/*/*.jpg, try:

echo */*/*/*/*.jpg | xargs ls 

xargs(1) knows, what the maximum number of arguments is on the system and will break up its standard input to call the specified command-line multiple times with no more arguments than that limit, whatever it is (you can also set it lower than the OS' maximum using the -n option).

For example, suppose, the limit is 3 arguments and you have filefive files. In that case xargs will execute ls twice:

  1. ls 1.jpg 2.jpg 3.jpg
  2. ls 4.jpg 5.jpg

Often this is perfectly suitable, but not always -- for example, you can not rely on ls(1) sorting all of the entries for you properly, because each separate ls-invocation will sort only the subset of entries given to it by xargs.

Though you can bump the limit as suggested by others, there will still be a limit -- and some day your JPG-collection will outgrow it again. You should prepare your script(s) to deal with an infinite number...

Instead of ls */*/*/*/*.jpg, try:

echo */*/*/*/*.jpg | xargs ls 

xargs(1) knows, what the maximum number of arguments is on the system and will break up its standard input to call the specified command-line multiple times with no more arguments than that limit, whatever it is (you can also set it lower than the OS' maximum using the -n option).

For example, suppose, the limit is 3 arguments and you have file files. In that case xargs will execute ls twice:

  1. ls 1.jpg 2.jpg 3.jpg
  2. ls 4.jpg 5.jpg

Often this is perfectly suitable, but not always -- for example, you can not rely on ls(1) sorting all of the entries for you properly, because each separate ls-invocation will sort only the subset of entries given to it by xargs.

Though you can bump the limit as suggested by others, there will still be a limit -- and some day your JPG-collection will outgrow it again. You should prepare your script(s) to deal with an infinite number...

Instead of ls */*/*/*/*.jpg, try:

echo */*/*/*/*.jpg | xargs ls 

xargs(1) knows, what the maximum number of arguments is on the system and will break up its standard input to call the specified command-line multiple times with no more arguments than that limit, whatever it is (you can also set it lower than the OS' maximum using the -n option).

For example, suppose, the limit is 3 arguments and you have five files. In that case xargs will execute ls twice:

  1. ls 1.jpg 2.jpg 3.jpg
  2. ls 4.jpg 5.jpg

Often this is perfectly suitable, but not always -- for example, you can not rely on ls(1) sorting all of the entries for you properly, because each separate ls-invocation will sort only the subset of entries given to it by xargs.

Though you can bump the limit as suggested by others, there will still be a limit -- and some day your JPG-collection will outgrow it again. You should prepare your script(s) to deal with an infinite number...

Source Link
Mikhail T.
  • 864
  • 10
  • 26

Instead of ls */*/*/*/*.jpg, try:

echo */*/*/*/*.jpg | xargs ls 

xargs(1) knows, what the maximum number of arguments is on the system and will break up its standard input to call the specified command-line multiple times with no more arguments than that limit, whatever it is (you can also set it lower than the OS' maximum using the -n option).

For example, suppose, the limit is 3 arguments and you have file files. In that case xargs will execute ls twice:

  1. ls 1.jpg 2.jpg 3.jpg
  2. ls 4.jpg 5.jpg

Often this is perfectly suitable, but not always -- for example, you can not rely on ls(1) sorting all of the entries for you properly, because each separate ls-invocation will sort only the subset of entries given to it by xargs.

Though you can bump the limit as suggested by others, there will still be a limit -- and some day your JPG-collection will outgrow it again. You should prepare your script(s) to deal with an infinite number...