How to delete the contents of a file
I just learn the command "diff"
now I have 2 files named text1 and text2 and the contents are like this : text1: a b c ================ text2: c d e ================ now I use the command : diff -u text1 text2 > text 3 and the result will be : --- text1 +++ text2 -a -b +d +e c ================= I want to keep the same contents in 2 files how should I do please help me thank you. |
You mean you want to apply the text3 file so text1 and text2 are the same?
It helps you think about it if you alter your filenames slightly: diff file1 file2 > file12.diff file12.diff contains instructions- to turn file1 into file2, it is called a "patch". (A whole lot of stuff probably just snapped into perspective?) patch file1 file12.diff The result will still be called file1 - you can use patch and diff with version numbers to help with this. |
I think I didn't explain my question clearly...
if i have a file named text3 and the contents are as below: ================================================================ +a +b c -d -e ================================================================ all i want to do is to delete the line being with "+" and "-" then the file text3 will have the content: ================================================================== c ================================================================== Is there any linux command can help me delete the line in the content? I have one more question here, how can I use "sort" to make the text3 contents like this: ===================================================================== c +a +b -d -e ===================================================================== I just want to pick up the lines without starting symbol "+" and "-" |
Quote:
Try this: fgrep -xf file1 file2 |
Quote:
thank you and thank Simon Bridge for helping solve the problem. |
Ah - so you wanted to find what files text1 and text2 had in common?
|
Quote:
However, You let me learn more about linux command, I am appreciated. |
All times are GMT -5. The time now is 09:21 PM. |