paste command with file headers paste command with file headers unix unix

paste command with file headers


you'll have to rewrite (or make temp copies) to include the fileName as the header. for f in FILE* ; do { echo "$f" ; cat $f ; } >$f.tmp && mv $f.tmp $f amd then your paste cmd. I think file1 file11 file111 will be the first 3 columns (for example), so better check that out first. You'll need to renamed files as file0001 to get a clean list Good luck. – shellter


If you're using a shell like bash that supports arrays, you can put all the files you care about in one, and print out it separated by tabs for the header and then call paste with the files in the array:

files=( *_count )( IFS=$'\t'; printf "%s\n" "${files[*]%_count}"; paste "${files[@]}" ) > output.tsv