Merge linux commands - rm and diff

2

I'm learning how to use Linux with the OpenSuse IDE version 13.1.

I would like to know if it is possible to merge the commands rm -r with diff - r ?

Objective

Remove files 1.txt , 2.txt , 2.txt from path1 , since it does not have path2 .

    
asked by anonymous 22.05.2015 / 01:12

2 answers

2

You can directly use the command rsync , example:

To use path2 as the "template":

rsync -r --delete path2/ path1

Important : The / toolbar is important for copying directory content and the directory itself.

:)

    
23.05.2015 / 07:50
1

I believe you can use the xargs command. Take a look at the manual for details.

It would be something like (not exactly):

diff -r path1 path2 | xargs rm

The output of diff has a few more words than the file names ( Only in path1: , for example), so you may need to handle a regular expression. >     

22.05.2015 / 16:43