Find all files with the extension .sh in the root directory of the workspace and apply the command sed '/^$/d' to each of them. Implement this as a reusable shell script named run.sh that takes the root directory as an optional argument and performs an in place update by removing blank lines from every matching file without touching non target files. The script should be safe to run in a controlled workspace and should report how many files were processed.
How to proceed:
Create a script named run.sh. It should determine the target root directory from the first argument or environment variable ROOT_DIR, defaulting to the current directory if neither is provided.
Use find to locate files ending in .sh under the target root directory, selecting only regular files.
For each file, run sed '/^$/d' on the file and write the output back to the same file using a temporary file to avoid portability issues.
Print a short summary of the number of files updated.
Deliverables:
A single executable script named run.sh. When invoked, it processes all .sh files under the root directory and applies the requested transformation.
Example usage:
./run.sh /workspace
ROOT_DIR=/workspace ./run.sh
If no argument is given, the script uses the current directory.