git mv
внутри оболочки петли?
What's the purpose of git-mv?
(Предполагая, что вы находитесь на платформе с разумной оболочкой!)
Опираясь на @ Джонатан-camenish: # (может кто-то изменить это в реальной ссылке?)
# things between backticks are 'subshell' commands. I like the $() spelling over ``
# git ls-files -> lists the files tracked by git, one per line
# | grep somestring -> pipes (i.e., "|") that list through a filter
# '|' connects the output of one command to the input of the next
# leading to: for file in some_filtered_list
# git mv f1 f2 -> renames the file, and informs git of the move.
# here 'f2' is constructed as the result of a subshell command
# based on the sed command you listed earlier.
for file in `git ls-files | grep filenamematch`; do git mv $file `echo $file | sed -e 's/%filenamematch%/%replacement%/'`; done
Вот уже пример (в Баш или аналогичный)
mkdir blah; cd blah;
touch old_{f1,f2,f3,f4} same_{f1,f2,f3}
git init && git add old_* same_* && git commit -m "first commit"
for file in $(git ls-files | grep old); do git mv $file $(echo $file | sed -e 's/old/new/'); done
git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# renamed: old_f1 -> new_f1
# renamed: old_f2 -> new_f2
# renamed: old_f3 -> new_f3
# renamed: old_f4 -> new_f4
#
: http://en.wikibooks.org/wiki/Ad_Hoc_Data_Analysis_From_The_Unix_Command_Line/
Есть ли у вас пример? Что такое% filenamematch%; это всегда в начале, конце или середине или что? Как выглядит %%%%? – GoZoner
Это может person.rb или lookitisa_person_here.html. В обоих случаях человеку нужно сопоставить и изменить его на что-то другое. Также должно быть чувствительно к регистру – Jonathan