I have some Perl files which I have to modify through a simple sed
call. Basically, I have to remove the first line of all of them. Currently, I managed to do this :
find <PATH> -type f -name "*.pl" -exec sed -i '1d' {} \;
However, I am using this line in a script and I would it to be a bit more... talkative. Thus, I decided to echo a counter (in real time), that would show how many files have been processed so far.
I know the count of Perl files can be retrieved through
PERL_FILE_COUNT=$(find <PATH> -name "*.pl" | wc -l)
Currently, I have this
remove_first_line()
{
count=0
echo -ne "Removing first line of Perl files ..."
find <PATH> -type f -name "*.pl" -exec sed -i '1d' {} \; >/dev/null 2>&1
if [ $? -eq 0 ]
then echo "OK"
then echo "FAILED"
fi
}
Now, what I would like as an output, would be something like this:
"Removing first line of Perl files ... 1/209209"
And the value should be automatically updated. But I don't see how to increment the count
variable with my find/exec statement. Basically, each time sed
finished working a file, it should increment the count
variable.
find <PATH> -name "*.pl" | wc -l
, thewc
command output will only be executed once the pipe is closed, not for every line.