Artificial intelligent assistant

Paste & Brace Expansion vs Wildcard Why does a brace expansion behave differently than wildcard in combination with `paste`? Example: Assume we have multiple folders, each containing the same-structured tsv and want to create a 'all.tsv' containing the 5th row of each of those. The two commands behave differently: paste -d, <(cut -d$'\t' -f5 {test,test1,test2}/example.tsv) > all.tsv vs paste -d, <(cut -d$'\t' -f5 test*/example.tsv) > all.tsv The first creates a tsv with 3 columns as expected, the second one creates a single columned tsv with the values beneath each other. My problem is that list of folders is arbitrarily big, potentially quite long and not sequential. Is there a way to achieve the same behavior as brace expansion with wildcard without moving to a bash script and iteration over the folders? Using GNU bash

The behaviour you're looking for is a bug that was fixed between bash-3.2 (the version found on macOS), and bash-4.0. From the CHANGES file:

> rr. Brace expansion now allows process substitutions to pass through unchanged.

For a one-liner, you might try awk:


awk -F '\t' {FNR != NR {exit} {out=$5; for (i = 2; i < ARGC; i++) {getline < ARGV[i]; out = out "," $5}; print out}' test*/example.tsv


Explanation:


FNR != NR { exit } # Exit after first file is finished.

{
out=$5; # save the first file's fifth field
for (i = 2; i < ARGC; i++) { # loop over the remaining arguments (filenames).
getline < ARGV[i]; # Read in the next line from i-th file.
out = out "," $5 # save fifth field of the line just read
};
print out # print saved columns.
}

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 61dc632562e62fc6f9b3e2fae6b0727c