Reputation: 119
Lets say i have a file name demo which contains an essay. how can i sort a the file alphabetically and then compare it the result with a file name demo2 using sed or anything else.
Upvotes: 1
Views: 1266
Reputation: 28608
Probably best to use diff
:
for this purpose. Something like this:
sort demo > demo_sorted
sort demo2 > demo2_sorted
diff demo_sorted demo2_sorted
You can read starting from here
about the different versions of the output you can produce.
Upvotes: 0
Reputation: 18359
First, sort both files, then diff
them:
sort demo1 > demo1sorted
sort demo2 > demo2sorted
diff demo1sorted demo2sorted
Upvotes: 0