Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

paste command with file headers

I have 178 files with an extension _count and I want to use paste command with the name of the file as the header, say

File1_count

abc
def 
gfh

FILE2_count

ijk
lmn
opq

FILE3_count

 rst
 uvw
 xyz

.... FILE178_count

 123
 456
 789

such that when I do paste *_count I will get the headers with the paste command as

 FILE1 FILE2  FILE3   ....  FILE178
  abc    ijk    rst            123
  def    lmn    uvw            456
  gfh    opq    xyz            789
like image 958
AishwaryaKulkarni Avatar asked Oct 30 '22 15:10

AishwaryaKulkarni


1 Answers

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

like image 59
Armali Avatar answered Nov 15 '22 08:11

Armali