1

I want to edit one text file, and it will automatically edited another text files. Is this possible? For example I have three save text files namely fileA.txt, fileB.txt and fileC.txt

I just want to edit fileC.txt and some of the chosen data will also save in the two other files.. I dont know if this is possible. I am just a new linux user. Thank you very much.

  • 2
    Are the three files the same to start with? – Buge Jun 30 '14 at 4:47
  • 1
    Do you have a preferred editor? Vim's 'scrollbind' and 'cursorbind' options might get you part way toward a solution. – cristoper Jun 30 '14 at 5:20
  • 2
    I don't understand your question. Do you want all of the files to be the same when you are finished? Perhaps ln or ln -s is what you want? – BenjiWiebe Jun 30 '14 at 13:52
2

I just want to edit fileC.txt and some of the chosen data will also save in the two other files.

I'm not sure if you can do that right away from a/the text editor, but maybe you can set up a script to run after your edit, something like:

grep "value you want to save in the other files" C.txt >> A.txt
grep "value you want to save in the other files" C.txt >> B.txt

If this is not what you meant, please provide a full example (edit your question with it) of what will be your input, and your desired output.

1

I wanted to add a comment to Jim's answer but my rep is not high enough, apologize for writing this as a separate answer.

Agreed, this is not something you can do in vi. You would need to script something in place. If you give us a specific example, I'm sure a lot of us here will be able to give you a more meaningful answer.

As it is, you would need to do something like

1) edit file

2) run script that distributes edits to all other files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.