doulang2311
doulang2311
2013-04-30 22:27

Comm,awk替代php

已采纳

I have 2 files:
images1.txt
--file1
--file2
--file5
--file6
--file7
images2.txt
--file1
--file5
--file6

I need to be created file images_to_delete.txt with expected result:
images_to_delete.txt
--file2
--file7

I know i could do this with bash using command:

awk 'NR==FNR{a[$0];next}!($0 in a)' images2.txt images1.txt > images_to_delete.txt

Is there any possibility to do this in PHP without using shell_exec?

Thank you.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • dpf5207 dpf5207 8年前

    By using these :

    read files into an array file function

    get difference between two arrays array_diff function

    点赞 评论 复制链接分享

为你推荐