Make this command better
-
While I use Linux (Feodra) daily, I do not use
rsync
andsed
every day.I have a folder with two sub directories.
Each subdirectory contains files form two different PBX systems.
I wan to compare the filenames to get a list of things shared or only on a specific system.This works, but I assume a could do it better.
rsync -n -a -i --delete newton/ edison/ | sed 's/*deleting /only edison/g' | sed 's/>f+++++++++/only newton/g' | sed 's/>f.[.s]t....../on both /g' | sed '/.d..t...... .\//d'
Output of
rsync without the
sed` tweaks:[jbusch@lt-jared context_dump]$ rsync -n -a -i --delete newton/ edison/ *deleting context_ivrSNOW .d..t...... ./ >f+++++++++ context_ata-outbound >f..t...... context_default >f.st...... context_main
Output after
sed
only edison context_ivrSNOW only newton context_ata-outbound on both context_defualt on both context_main
Explanation of the bits:
List the diffrences:rsync -n -a -i --delete newton/ edison/
Delete means only on Edison:sed 's/*deleting /only edison/g'
Plus' mean only on Newton:'s/>f+++++++++/only newton/g'
File on both with different size or timestamp:sed 's/>f.[.s]t....../on both /g'
Just remove the empty directory line:sed '/.d..t...... .\//d'
-
What is this doing or not doing that you need it to do?
-
@DustinB3403 said in Make this command better:
What is this doing or not doing that you need it to do?
@JaredBusch said in Make this command better:
This works, but I assume a could do it better.
.....
-
@JaredBusch said in Make this command better:
@DustinB3403 said in Make this command better:
What is this doing or not doing that you need it to do?
@JaredBusch said in Make this command better:
This works, but I assume a could do it better.
.....
Better is not a useful qualifier! Better how?!
-
@JaredBusch : I'm not certain if this fits the bill, but what about the "diff" command? Of course, this does nothing to sync the files but does offer a way to simply compare the directories.
diff -rs manxam jaredbusch
This will get you :
Files /home/manxam/TEST and /home/jaredbusch/TEST are identical Only in /home/manxam: i_am_manxam Only in /home/jaredbusch: you_are_jared