Remove the same files in two folders

有時在整理照片或文件時, 需要比對2個資料匣, 把重覆的檔案拿掉. Dwonload Source Here function usage(){ echo "Find the same file in two folders and remove it." echo "usage : ./comp-rm.sh target-dir source-dir" echo "remove the same files in target-dir." } if [ $# -ne 2 ]; then usage exit 1 fi target_dir=$1 source_dir=$2 f_list1=$(find "$target_dir" -type f) f_list2=$(find "$source_dir" -type f) for i in $f_list1; do echo $f_list2 | grep $(basename $i) >/dev/null && hit_str+=$i";" done if [ -z $hit_str ]; then echo "list is empty....

June 19, 2013 · 1 min · oopsmonk

Raspberry Pi Setup

Install Raspbian “wheezy” image Download image from Raspberry Pi offical website Mount HOME to HDD Copy HOME data to disk $ sudo mkdir /media/new_home $ sudo mount /dev/sda1 /media/new_home $ sudo rsync -aXS /home/. /media/new_home/. $ sudo umount /media/new_home fstab #get disk UUID $ sudo blkid /dev/mmcblk0p1: SEC_TYPE="msdos" LABEL="boot" UUID="936C-7122" TYPE="vfat" /dev/mmcblk0p2: UUID="c1198422-7a7c-4863-8a8f-45a1db26b4f2" TYPE="ext4" /dev/sda1: UUID="2cd990b5-6c27-4933-95d0-fd00b000fe77" TYPE="ext4" #modify fstab $ echo "UUID=2cd880b5-6c27-4933-95d0-fd00b000fe77 /home ext4 defaults 0 2" | sudo tee --append /etc/fstab #mount HOMW without reboot....

June 15, 2013 · 5 min · oopsmonk