Hi i got many files which look like this:

relation:
xxxxxx
birthday:
xxxxxx
age:
xxxxxx
livingsituation:
xxxxxx
place:
xxxxxx
school:
xxxxxxx
job:
xxxxxxx
but i also got other files which look like this:

relation:
xxxxxx
age:
xxxxxx
livingsituation:
xxxxxx
place:
xxxxxx
job:
xxxxxxx in which xxxxxx is variable

My problem is that all files should get the same order, as you can see in the example above, school is left out in the second file.

Now i need something which checks whether there is a certain line in the file, like school or birthday, and if not, that school or birthday is inserted. And plus that there should also be an empty line inserted under the word just inserted.

So actually the second file should look, after processing in shell script, exactly like the first one.

Any ideas? thanks

I would use a combination of grep and sed to do this... use grep for the pattern matching, and use sed to do the inline text editing. Do you have to do this with just shell script? Personally, I find it a lot easier to tackle this type of problem with perl or python.

-Josh
www.qbangsolutions.com

Use awk (hint: Use getline()). Post your code and I'll correct it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.