2
I’m learning to use Linux with Opensuse IDE version 13.1.
I wonder if it is possible to merge the commands rm -r
with diff - r
?
Goal
Remove the files 1.txt
,2.txt
,2.txt
of path1
, because it does not possess in the path2
.
2
I’m learning to use Linux with Opensuse IDE version 13.1.
I wonder if it is possible to merge the commands rm -r
with diff - r
?
Remove the files 1.txt
,2.txt
,2.txt
of path1
, because it does not possess in the path2
.
2
Direct use of the command rsync
, example:
To use the path2 as "model":
rsync -r --delete path2/ path1
Important: The bar /
is important to copy the contents of the directory and the directory itself.
:)
1
I believe you can use the command xargs
. Take a look at the manual for details.
It would be something like (not exactly):
diff -r path1 path2 | xargs rm
The exit of diff
has a few more words than not the file names (Only in path1:, for example), then you may need to deal with a regular expression.
Browser other questions tagged linux terminal
You are not signed in. Login or sign up in order to post.