grep --line-number --with-filename --recursive "«first line regex»" «/source/directory/»* | grep --only-matching "^[^:]*:1:" - | sed s/:1://g | xargs --interactive -i mv {} {}«.newextension»so that for examplegrep --line-number --with-filename --recursive "^#\!/bin/" /home/username/* | grep --only-matching "^[^:]*:1:" - | sed s/:1://g | xargs --interactive -i mv {} {}.shwould recursively rename all shell scripts (or at least all files beginning with "#!/bin/" on the first line) to «filename».sh in /home/username.You are not logged in, either login or create an account to post comments
posted by jjwiseman at 1:27 PM on December 29, 2012