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 throughPERL_FILE_COUNT=$(find <PATH> -name *.pl | wc -l)Currently, I have thisremove_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/209209And 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.
Count result in a find/exec statement
bash;shell;find
If you have bash 4, consider using globstar instead. It gives you recursive globbing.shopt -s globstarperlz=( **/*.pl ) # */ Hack to fix syntax highlightingtotes=${#perlz[@]}i=0for file in ${perlz[@]}; do    printf 'Removing first line of Perl files  %d/%d\r' $((++i)) $totes    ed -s $file <<< $'1d\nw' # You can use `sed` if you want to, but ed is an actual file editordoneecho # print a final newlineThis solution will work across files with crazy characters in their names and avoids a subshell.But if bash 4 isn't an option, you can recreate this solution using find -exec +:find . -name '*.pl' -exec bash -c 'totes=$#  i=0  for file; do    printf Removing first line of Perl files  %d/%d\r $((++i)) $totes    ed -s $file <<< $'\''1d\nw'\'' # Avoid these leaning toothpicks by putting this                                     # script in a file.  done  echo # print a final newline' bash {} +However, this is subject to your system's ARG_MAX (unlike the above), so if the number of files is very large you could still end up with multiple runs over subsets of the files.