New answers tagged

2

The files you are seeing there are present in both directories but are different; that's why they show up. If you run one of those diff commands you can see what it thinks are different eg diff -r /home/user/nodejs_apps/angular2-esnext-starter/dist/client/vendor.js.map /home/user/nodejs_apps/angular2_oauth_seed_app/dist/client/vendor.js.map If you want ...


1

Speed and reliability are often opposite requirements. diff (or cmp) would compare the files bit-by-bit, which would give the most reliable answer. (Use diff -q if you only want to know if the files are the same.) To make it faster, you'd have to skip on either reading the files in full, and count on timestamps; or skip on the data transferred, which ...


5

If you use diff, it always reads the file contents to pick up any differences between their contents. Rsync, by default, will not read the contents of files if the filename, modification time and file size between the two are the same. If these are the same, it assumes the file contents are the same and doesn't bother reading them. This will make it ...


1

diff <(sort -u names2.txt) <(sort -u names1.txt) | sed -n -e 's/^> //p' > missing_names.txt or diff <(sort -u names1.txt) <(sort -u names2.txt) | sed -n -e 's/^< //p' > missing_names.txt Either of those will give you ONLY the names that are in names1 but not names2. diff (without any output-format options like -u) ...


0

cat name_1.txt | while read line do grep -q "$line" name_2.txt if [ "$?" -gt "0" ]; then echo "$line" >> name_3.txt fi done NOTE: Assuming name_1.txt and name_2.txt contains only names.


3

Short: you don't do this. Long: Here's why A unified-diff is a script, using line-numbers and counts which tie-in to the content of the diff. It's possible to manually make simple changes to this script (I do...), but A unified-diff is mainly useful with the patch program, and patch checks for consistency between the parts of a diff, and patch will reject ...


0

You can use the -v (verbose) and -n (dry run) parameters to the rsync command to simulate and view file changes. rsync -van src_dir/ dest_dir/ --delete Note that rsync prior to 1.0.1 does not work well when the file exists in both destination dir and link-dest dir.


3

A solution with bash, join, paste, and bad taste: #! /usr/bin/env bash if [ $# -lt 3 ]; then exit 1; fi files=( '' "$@" ) declare -a temps for ((i=0; i<=$#; i++)); do [ $i -eq 0 -o -f "${files[$i]}" ] || exit 1 temps[$i]=$( mktemp -t "${0##*/}"_$$_XXXXXXXX ) || exit 1 done trap 'rm -f "${temps[@]}"' EXIT HUP INT QUIT TERM cat "$@" | sort -u &...


5

A general solution with awk: requires GNU awk gawk -v level=0 ' FNR==1 {level++; head[level]=FILENAME} !seen[$1]++ { n++; idx[$1] = n } { out[idx[$1]][level] = $1 } END { for (j=1; j<=level; j++) { printf "%s\t", head[j] } print "" for (i=1; i<=n; i++) { for (j=1; j<=level; j++)...


6

You could process each file and print a line with some character e.g. X for every missing number in the sequence 1-max (where max is the last number in that file), paste the results then replace that character with space: paste \ <(awk 'BEGIN{n=1};{while (n<$1) {print "X";n++}};{n=$1+1};1' file1) \ <(awk 'BEGIN{n=1};{while (n<$1) {print "X";n++}}...


0

I figured it out! join –v 1 file2 file1


2

you can do this with awk awk 'FNR==NR{a[$1];next};!($1 in a)' file1 file2


2

Rsync synchronizes files unless it is able to decide that they're the same without comparing their contents. It might synchronize a file and realize that there aren't any differences, if it wasn't able to tell that the files are identical without checking the contents. By default, rsync decides that two files are identical (and thus skips reading their ...


3

rsync will report changes for permissions differences timestamp differences content (and filesize) differences In comments, @roaima pointed out that there is an option to give a summary of these changes, in the rsync manual page: -i, --itemize-changes output a change-summary for all updates You may find it useful, though the summary is terse and ...



Top 50 recent answers are included