how to remove leading whitespace from filenames/folders snow?
- by timoto
how do I remove leading whitespace from filenames/folders in OSX snow ?
As provided below by Lri I was able to remove trailing whitespace using this
#!/bin/bash
IFS=$'\n'
for d in {1..9}; do
find ~/Desktop -name '* ' -depth $d | while read f; do
mv "$f" "$(sed 's/ *$//' <<< "$f")"
done
done
Now I'm trying to remove leading whitespace with this
#!/bin/bash
IFS=$'\n'
for d in {1..9}; do
find ~/Desktop -name '* ' -depth $d | while read f; do
mv "$f" "$(sed 's/^ *//;s/ *$//' <<< "$f")"
done
done
but it doesn't work.
What am I doing wrong ?