Skip to content
Advertisement

How do I sort a list of files and concatenate the contents in bash?

This works:

JavaScript

But when I try to sort the the filenames, remove the newline the list of filenames that are piped to cat look identical to the previous but sorted:

JavaScript

However cat returns this error:

JavaScript

Advertisement

Answer

Your xargs statement is expecting null terminated entries.

JavaScript

If your filenames or directories have spaces, then yes, use the null terminated way.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement