我有这个bash脚本,我需要修改它所以它还包括“=”和“;”。
感谢。
#!/bin/bash
find . -depth -name "*[,&<>*?|\":'()]*" | # Find all files or folders containing 'bad' characters.
while read FILEDIR # Read them line-by-line.
do
DIR="${FILEDIR%/*}" # Get the folder its inside
FILE="${FILEDIR/*\/}" # Get the plain name.
NEWFILE="${FILE//[,&<>*?|\":\'()]/_}" # Substitute _ for bad things.
mv "$DIR/$FILE" "$DIR/$NEWFILE" # Rename it.
done
答案 0 :(得分:0)
NEWFILE=$(echo -n "$FILE" | tr -c '[:alnum:][:blank:]_-' _)
不幸的是,它会花费每个文件的分叉。