Reputation: 205
So I have a bunch of files like:
Aaron Lewis - Country Boy.cdg
Aaron Lewis - Country Boy.mp3
Adele - Rolling In The Deep.cdg
Adele - Rolling In The Deep.mp3
Adele - Set Fire To The Rain.cdg
Adele - Set Fire To The Rain.mp3
Band Perry - Better Dig Two.cdg
Band Perry - Better Dig Two.mp3
Band Perry - Pioneer.cdg
Band Perry - Pioneer.mp3
and I need to have the leading whitespace removed in bash or fish script.
Upvotes: 5
Views: 3388
Reputation: 2357
To remove the leading white space char in the file names you provided you can use:
IFS=$'\n'
for f in $(find . -type f -name ' *')
do
mv $f ${f/\.\/ /\.\/}
done
This:
bash
substring substitution.Upvotes: 5
Reputation: 77155
You don't need sed
for this. Just use bash
string function:
for file in /path/to/files/*;
do mv "$file" "${file# *}";
done
Upvotes: 0
Reputation: 8897
cat <file> | sed -e 's/^[ ]*//'
should do the trick. Capture stdout and write to a file.
Upvotes: 0
Reputation: 58304
for x in \ * ; do
mv "$x" `echo "$x" | sed "s/^ +//"`
done
This is quick and dirty.
Upvotes: 0