简体   繁体   中英

Bash. Work with diff

Write a script to compare files in two directories, ignoring the changes associated with the addition of blank lines, spaces, tabs, and also use wildcards in excludeFiles, to exclude from the comparison of unnecessary files. The file specified as a parameter, write down the names of these files, their i-node, and creation date.

I know how to do first part(before point).

   diff -rwBd -X excludeFiles mydir1 mydir2 > changes.diff

But don't understand how to do second part "The file specified as a parameter, write down the names of these files, their i-node, and creation date."?? I think i need to use ls....

You could ignore diff output (-q), get file names and use ls for inodes (-i) and ctime (-c)

$ diff -rwBdq -X excludeFiles mydir1 mydir2 | awk '{print $2" "$4}' | xargs ls -lic
2415432 -rw-r--r-- 1 user group  4163 Nov  6 15:21 mydir1/file1
2415434 -rw-r--r-- 1 user group  1042 Nov  6 15:21 mydir2/file1
2415433 -rw-r--r-- 1 user group  4163 Nov  6 15:21 mydir1/file2
2415435 -rw-r--r-- 1 user group  1042 Nov  6 15:21 mydir2/file2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM