General discussion

Locked

Merging of two files using unix utilitie

By vaddavalli ·
I have one static file with some tags in it. And I have one data file with the values and its position like page number, line number, column number.
No how do I merge these to files by using unix utilities.

This conversation is currently closed to new comments.

17 total posts (Page 1 of 2)   01 | 02   Next
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Merging of two files using unix utilitie

by VinnyD In reply to Merging of two files usin ...

You did not say what the resulting file should look like.
To combine two files together you can use the copy command.


cp sourcefile1+sourcefile2 destinationfile

That will put the two files together in sequencial order.

To merge them together like tags, page#, line#, column# you have to write a program to do it.

Collapse -

Merging of two files using unix utilitie

by vaddavalli In reply to Merging of two files usin ...

The question was auto-closed by TechRepublic

Collapse -

Merging of two files using unix utilitie

by lurid In reply to Merging of two files usin ...

cat file1 >> file2
this will append file2 to the end of file one

Collapse -

Merging of two files using unix utilitie

by vaddavalli In reply to Merging of two files usin ...

The question was auto-closed by TechRepublic

Collapse -

Merging of two files using unix utilitie

by tyswidan In reply to Merging of two files usin ...

IJust use the simple cat utility, for example if you have fil1 ( with tags)
and file2 ( with the data), all you have to do is:

cat file2 >> file1
done.

hope that helps.

Collapse -

Merging of two files using unix utilitie

by vaddavalli In reply to Merging of two files usin ...

The question was auto-closed by TechRepublic

Collapse -

Merging of two files using unix utilitie

by gordon In reply to Merging of two files usin ...

If the above answers your question, look no further, otherwise: Welcome to the world of hard-core unix: You need to refine your question. If the files are line-for-line ok and you just want to do a "column-merge" look at: paste -d If the tags in the first file refer to a line in the second file, then you may need to sort one (or both) files first-> get rid of duplicates (uniq) -> get rid of other stuff (cut, grep, sed) and then finally join (one of the harder commands to master). I had two files I had to merge together: One had IP addresses and printer names, the other had printer names and printer setups. I "linked" them together with the printer name, but had a lot of cleaning up to do first... Presevere, there is daylight after you master these. (My end file was 2900 bytes long, so it's a LOT smaller than any 'C' program)

Collapse -

Merging of two files using unix utilitie

by vaddavalli In reply to Merging of two files usin ...

The question was auto-closed by TechRepublic

Collapse -

Merging of two files using unix utilitie

by wcf In reply to Merging of two files usin ...

There are too many unknowns in your question for a definitive answer, but a general solution is to broaden your constraints slightly and use Perl, available on most systems. One line of code to open each file, a line or two of code to read the datafile into a hash table, and another line or 2 to scan the tag table gor tags and substitute from the hash table. This kind of problem is why Perl exists!

Collapse -

Merging of two files using unix utilitie

by vaddavalli In reply to Merging of two files usin ...

The question was auto-closed by TechRepublic

Back to Linux Forum
17 total posts (Page 1 of 2)   01 | 02   Next

Operating Systems Forums