Wups: Re: Compare folders and find missing files
Francis Grizzly Smit
grizzly at smit.id.au
Wed Mar 25 20:48:10 UTC 2020
On 25/03/2020 23:54, Ken D'Ambrosio wrote:
> D'oh. I checked my one-liner, noted I had a goof or two... and then
> sent it without fixing.
> Gonna be that type of day, I'm afraid. New-and-improved (a/k/a
> "functional") below.
>
> On 2020-03-25 08:52, Ken D'Ambrosio wrote:
> [...]
> less elegant, is more explicit, and doesn't
>> repeatedly walk the compared tree:
> cd /media/project && find . -type f | while read fname; do ls
> ~Documents/sub-tree/$fname > /dev/null 2> /dev/null || echo "$fname
> not there."; done
cd /media/project
for f in *
do
if [ ! -e ~Documents/sub-tree/"$f" ]
then
echo "$f missing."
fi
done
is good for one level, but I'd use diff -r /media/project/
~Documents/sub-tree/
for a more complex (deeper) case
>>
>> Note that there will be a superfluous -- but functionally noop -- "./"
>> in the path shown of any missing files.
>>
>> None of which invalidates the point about diff possibly being the most
>> efficient method.
>>
>> $.02,
>>
>> -Ken
>
--
.~. In my life God comes first....
/V\ but Linux is pretty high after that :-D
/( )\ Francis (Grizzly) Smit
^^-^^ http://www.smit.id.au/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20200326/658fb11d/attachment.html>
More information about the ubuntu-users
mailing list