/ Published in: Bash

A couple of snippets useful for file management. I use these to make sure I understand how many files I'm about to modify, and then rename them.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
## Use find to search for the files I want recursively from the current path ## Powerful utility, man find to read the man pages find . -name "*.rhtml" # List all files that end in .rhtml find . -type f # Find all regular files ## I can use wc (word count) with the -l flag to count the number of returned lines find . -name "*.rhtml" | wc -l # Count the number of files that match ## I can then add a while and mv command to rename the files find . -name "*.rhtml" | while read f; do mv ./"$f" "${f%rhtml}html.erb"; done
Comments
