#!/bin/bash # This script should be executed without "./" in front of this script file name. # This script replaces all symbolic link with their original files with modified time stamp one minute after that of the each symbolic link. # Place this script in a directory files and directories of which is/are to be dealt. if [ -e log ];then echo "This script will generate, use and delete a file named 'log'. This directory contains a file named 'log'. I abort to keep the file." exit 1 fi find . -type l -exec ls -l --time-style=long-iso {} \;|tr -s " "|cut -d " " -f 6-|sed -e "s/-//" -e "s/-//" -e "s/ //" -e "s/://" > log number=$(wc -l log|cut -d " " -f1) i=1 while [ $i -le $number ];do line=$(sed -n -e ${i}p log) i=$(expr $i + 1 ) modifiedtime=$(echo $line|cut -d " " -f1) file=$(echo $line|sed -e "s/^[0-9]* //" -e "s/ -> .*$//") origin=$(echo $line|sed -e "s/^.* -> //") if [ -n "$(echo $file|grep " ")" ];then echo "This script cannot deal a file \"$file\" with full path containing space. modified date and name of symbolic link original file $line" continue fi if [ -n "$(echo $origin|grep " ")" ];then echo "This script cannot deal an original file \"$origin\" with full path containing space. modified date and name of symbolic link original file $line" continue fi rm $file cp $origin $file touch -m -t ${modifiedtime}.60 $file done rm log