#!/bin/bash for i in $(find ../public/it4i -type f -printf "%P\n" | grep -v .gitkeep) ; do short=$(echo $i | sed -e 's/.*\/\([^\/]*\)\/\([^\/]*\)$/\1\/\2/'); for f in $(grep -rl "$short)"); do sh=$(echo $short | sed -e 's/\//\\\//g') ie=$(echo $i | sed -e 's/\//\\\//g') sed -i "s/(.*$sh)/(\/it4i\/$ie)/" $f done done