Reputation: 35
This question is related to Bash - Compare 2 lists of files with their md5 check sums
My question is how to edit the following codes to show the entire path of the file instead just the name of it:
awk -F"/" 'FNR==NR{filearray[$1]=$NF; next }!($1 in filearray){printf "%s has a different md5sum\n",$NF}' file1 file2
and
awk -F"/" 'FNR==NR{filelist[$NF]=$NF; next;}!($NF in filelist){printf "%s is an extra file",$NF}' file1 file2
For more information please review the other question!
Thank you all for the time and help!
Upvotes: 0
Views: 132
Reputation: 85865
Using the GNU Awk
string manipulation split-function, to split the matching line, in this case a $0
and store it in the array
as individual elements.
awk -F"/" 'FNR==NR{filearray[$1]=$NF; next }!($1 in filearray){split($0,array," ");printf "%s has a different md5sum or do not exist in the vanilla core files\n",array[2]}' file2 file1
/home/user/vanila/file-4.php has a different md5sum or do not exist in the vanilla core files
and for the file(s)
awk -F"/" 'FNR==NR{filelist[$NF]=$NF; next;}!($NF in filelist){split($0,array," "); printf "%s is an extra file\n",array[2]}' file1 file2
/home/user/file-1.1.php is an extra file
Upvotes: 3