Remove all brackets in filename
Solution 1
i found this one liner and this work :
for x in *[*; do mv -- "$x" "${x//[/}"; done
this should do the job , just replace left or right bracket each time yu execute this commandl
Solution 2
Solution posted by @juicebyah will only remove the initial bracket. If OP wants to remove both brackets, it is better to use sed
in this way:
find . -type f -iname "*[*" | \
while IFS= read -r line; \
do mv "$line" "$(printf %s "$line" | sed -re 's/(\[|\])//g')"; done;
Related videos on Youtube
greg0ire
Updated on September 18, 2022Comments
-
greg0ire over 1 year
I've been using a symfony1 plugin repository in a project repository, using git-subtree, but I can't always see my history.
Basically, the plugin project has a composer.json file I merged the plugin under the
plugins/MyPlugin
subtree.When I do
git log
, I can see the history. However, when dogit log -p plugins/MyPlugin/composer.json
orgit log plugins/MyPlugin/composer.json
, I only see a merge commit. Why ?But maybe subtree isn't really the right tool. What I want to do is forget completely about the plugin repository and pretend that its commits actually happened in the project repository, modifying files in the plugins/MyPlugin directory.
EDIT Ok, I solved my problem by rewriting the plugin history with a
filter-branch
, and merging the result in the project repository. Still the first question remains. For science. -
Mathias Begert almost 9 yearsyou can lose the trailing
/
; so"${x//[}"
instead of"${x//[/}"
-
juicebyah almost 9 yearsnice! it works , remove all brackets in filename.
-
Gilles 'SO- stop being evil' almost 9 yearsMake that
"${x//[][]}"
to replace both brackets. (Yes, it does look weird.) -
cptMikky about 8 yearsAre you using BASH or ZSH? Are you sure you've copied the code correctly?