jkavx
asked on
Replace text in files under directory
I need to replace all instances of a sourced property file in all folders under a given directory.
so every instance of
. ~/abc/app_props.sh
replaced with
. ~/abc/app-props.sh
under ~/bin
Not sure how to do this.
so every instance of
. ~/abc/app_props.sh
replaced with
. ~/abc/app-props.sh
under ~/bin
Not sure how to do this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The above works if your sed implementation supports substitute-in-place ( -i ).
If your sed doesn't support it do
find ~/bin -type f | while read file; do
sed 's#. ~/abc/app_props.sh#. ~/abc/app-props.sh#' $file > $file.$$
mv $file.$$ $file
done
wmp