2

Such code

$ ls {a,b}{c,d}

runs ls command on following files: ac, ad, bc, bd.
Is there a simple way to reverse resolution order and generate such sequence: ac, bc,ad, bd?

edit
I want to run grep on particular subset of files inside a subset of directories like this:

$ grep 'find this' {sub_dir_one,sub_dir_two}/some_loc/{file_one,file_two}

I want lines from both file_one, then both file_two with respect to sub_dir_one and sub_dir_two order.

I just wonder if there's some nice trick which prevents me from using loop.

1 Answers1

2

According to bash man page, in the Brace expansion paragraph,

The results of each expanded string are not sorted; left to right order is preserved.

So an alternative is to use a for loop:

for i in file_one file_two; do
   grep 'find this' {sub_dir_one,sub_dir_two}/some_loc/"$i"
done
oliv
  • 2,586
  • 9
  • 14