hi, this script is just for 3 or less then 3 files as input. If you have more files, the logic needs to be changed as well, not only the ARGIND part. say you have 10 files, then one line could be
the script above cannot give you that output. So "extend" doesn't work. you have to rewrite.
awk can do this, but not so easy, at least I haven't thought a shortcut for that, glad to know if someone has. You may try write a python script. I think that wouldn't be complicated.
---------- Post updated at 14:45 ---------- Previous update was at 14:07 ----------
here is the py script to do your job.
PHP Code:
#!/usr/bin/python files=['file1','file2','file3'] dict={} len = files.__len__() for s in files: idx = files.index(s) f = open(s) line = [x.replace("\n","") for x in f.readlines()] for l in line: k,v = l.split(" ")[0], l.split(" ")[1] if(not dict.has_key(k)): dict[k] = list("-"*len) dict[k][idx] = v f.close()
keys = dict.keys() keys.sort() for k in keys: print k+" "+ reduce(lambda x,y: x + " " + y,dict[k])
save above codes to a .py file. e.g. t.py
then:
you could change the "files" list, add as many files as you want. of course, you can get the files list by a given path. e.g. os.listdir(path)...
hi all
i have 2 files f1 and f2
i have to combine these 2 files and make a new file f3
when i use paste f1 f2 >f3 its pasting vertically
but i want to paste horizontally
How to do ..
pls let me know (2 Replies)
I have 2 files that I need to combine.
One file is looks like this:
71664107;1;1;05-FEB-07;12-FEB-07;
The other file looks like this:
U;71664107;dummy;Pirovano;M;04-SEP-75;Georgia;MI;1;1;31;S;S;;;Y;05-02-2007;0;12-FEB-07;
I need to combine both files together. I need the shorter... (4 Replies)
Hi :
I have a file containing the print queues with their IP address. I wanted to combine the 'lpstat' output with their respective IP address.
For example :
zebhtrmb-6078 lgonzale priority 0 Mar 17 11:50 on zebhtrmb
with
zebhtrmb-6078 lgonzale priority 0 ... (1 Reply)
Hi All ,
Any one help me to combine two files in shell scripting .Below is my requrement
i have 2 files as follows
filea
newyork America
Texas America
london Engalad
Fileb
abc
def
xyz
i have to combine this file as follows
newyork America abc
Texas ... (1 Reply)
Ok here is what I have
file a
{{BEGIN}}
{{FAX
File b
5555464584
5555465292
5555465828
5555485930
5555474939
File C
}}
ON ORDERS LESS THAN 70 LBS AND THE PACKAGE IS A
COMBINED LENGTH AND GIRTH EQUAL TO OR LESS THAN
108" PLEASE UTILIZE UPS. ... (4 Replies)
I have multiple files; each file contains a certain data in a column view
simply i want to combine all those files into one file in columns
example
file1:
a
b
c
d
file 2:
1
2
3
4
file 3:
G (4 Replies)
Hi,
i have two files. i want to combine records from these two files in below manner :-
first line from first file(1st line)
2nd line from 2nd file(1st line)
3rd line from 1st file(2nd line)
4th line from 2nd file(2nd line)
so on.... (1 Reply)
I have n of files with ending with _ZERO.txt
need to combine all file ending with _ZERO.txt into 1 file
ex:
A_ZERO.txt
1
2
B_ZERO.txt
3
4
Output:
FINAL.txt
1
2 (3 Replies)
i use the split command to split a one terabyte backup file into 10 chunks of 100 GB each. The files are split one after the other. While the files is being split, I will like to scp the files one after the other as soon as the previous one completes, from server A to Server B. Then on server B ,... (2 Replies)