Skip to main content
Added example script and command
Source Link
unxnut
  • 6.1k
  • 2
  • 22
  • 28

It should be easy enough to write a little script that does what you want and exec the script as an argument to find. You already have the script and if you replace $filename by $1, you have it. Your script will be of the form

#!/bin/bash
sed -i 's/$pattern/$new_pattern/' $1
echo $1 >> changelog

Let us call this script ed_notify. Now, you can run it on selected files by

cat changelog >> changelog.old
rm changelog
find . -type f -a \( -name "*.txt" -o -name "*.git"\) -a -exec ed_notify {} \;

It should be easy enough to write a little script that does what you want and exec the script as an argument to find. You already have the script and if you replace $filename by $1, you have it.

It should be easy enough to write a little script that does what you want and exec the script as an argument to find. You already have the script and if you replace $filename by $1, you have it. Your script will be of the form

#!/bin/bash
sed -i 's/$pattern/$new_pattern/' $1
echo $1 >> changelog

Let us call this script ed_notify. Now, you can run it on selected files by

cat changelog >> changelog.old
rm changelog
find . -type f -a \( -name "*.txt" -o -name "*.git"\) -a -exec ed_notify {} \;
Source Link
unxnut
  • 6.1k
  • 2
  • 22
  • 28

It should be easy enough to write a little script that does what you want and exec the script as an argument to find. You already have the script and if you replace $filename by $1, you have it.