Question

I am generating thousands of md5sums of the same files that exists in different file servers, I'm looking to determine if any are corrupted (they are) and which ones. By comparing the md5 hashes and filtering out the ones that are different I can make an impossible task a bit more manageable.

The paths will be different in each list from each server, the md5sums and filenames will be largely the same.

In the below example, how can I remove the path from the middle so that it just shows the hash and then the filename, eg;

eg, what i have now 8937ebe2a584589063cd3f0d1536186a c:\test1\Homeland.S03E02.HDTV.x264-ASAP\homeland.s03e02.hdtv.x264-asap.rar

eg, what i want 8937ebe2a584589063cd3f0d1536186a homeland.s03e02.hdtv.x264-asap.rar

I think that I should be able to do it with cut but have not been able to figure it out yet. Some help would be much appreciated!

Thanks for looking Matt

Was it helpful?

Solution

$ cat file
8937ebe2a584589063cd3f0d1536186a c:\test1\Homeland.S03E02.HDTV.x264-ASAP\homeland.s03e02.hdtv.x264-asap.rar

$ sed 's/\([^ ]*\).*\\/\1 /' file
8937ebe2a584589063cd3f0d1536186a homeland.s03e02.hdtv.x264-asap.rar

$ awk -F'[ \\\\]' '{print $1, $NF}' file
8937ebe2a584589063cd3f0d1536186a homeland.s03e02.hdtv.x264-asap.rar
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top