Reputation: 21449
How can I join 2 ls results ? - I need this because the files are in 2 different directories and I need to sort them in different ways.
Anyway for the output I need a normal listing with both results.
Upvotes: 4
Views: 1780
Reputation: 2376
Perhaps find
is more useful here because of that "directory:" format that ls
uses when it's given more than one directory as an argument.
find /etc/dpkg/ /etc/apt -mindepth 1 -maxdepth 1 | sort
You can customize output if your find supports printf, for example
find /etc/dpkg/ /etc/apt -mindepth 1 -maxdepth 1 -printf "%f\n" | sort
Upvotes: 0
Reputation: 359965
No need to run ls
twice, just put multiple file specifications as arguments.
ls /path/to/first_file_spec* /different_path/to/second_file_spec*
Upvotes: 6
Reputation: 28598
This should do it:
{ ls folder1 && ls folder2; }
Got this from:
Try this example:
{ ls /etc/fonts && ls /etc/init; }|while read i; do echo $i; done
(hope you have these folders - replace if you don't).
Upvotes: 1