New answers tagged


Try this: #!/bin/bash if [ -f "$1" ]; then cp -v "$1" _"$1" rename -v 's/_(.+?)\./$1_copy\./' _"$1" fi The script checks if the input file that receives as input exists. In that case, it makes a temporary copy of the file and then renames such copy replacing the first dot in its name with the string _copy. I hope it is what you needed.


From the test directory, do: mv -t player *.txt Assuming all text files end in .txt. This will mv all .txt files from current directory (test/) to player/ subdirectory.


If you use an absolute path in a filter (include/exclude), it's interpreted starting from the root of the synchronization. You aren't excluding a directory in the source, or a excluding a directory in the destination, you're excluding a directory in the tree to synchronize. Thus: rsync -av --delete --progress --exclude "/folder4/mytestfolder1" /source/ ...


The rsync way given by Thane with Yamaneko additions work great but leave empty directories. For me the final solution was in two steps, first call rsync with full path, then a find command to remove all empty directories: rsync -rvcm --compare-dest=/tmp/org/ /tmp/new/ /tmp/difference/ find /tmp/difference/ -d -type d -empty -exec rmdir {} \; -print ...

Top 50 recent answers are included