开发者

simple diff question

开发者 https://www.devze.com 2023-04-02 06:54 出处:网络
file1.txt is 10 20 30 40 50 file2.txt is 10 20 40 60 70 80 I want output.txt to be a union of numbers in these two 开发者_如何学Pythonfiles but with no duplicates.

file1.txt is

  • 10
  • 20
  • 30
  • 40
  • 50

file2.txt is

  • 10
  • 20
  • 40
  • 60
  • 70
  • 80

I want output.txt to be a union of numbers in these two 开发者_如何学Pythonfiles but with no duplicates. Output.txt should be

  • 10
  • 20
  • 30
  • 40
  • 50
  • 60
  • 70
  • 80


If you don't need to preserve the order within the individual files:

cat file1.txt file2.txt | sort | uniq > output.txt
0

精彩评论

暂无评论...
验证码 换一张
取 消