Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env zsh
- # UIB-290708 DOUBLE SPACE TEXT FILES
- for file in **/*(.); do
- # Check if file is text.
- if file -b $file | grep -q "text"; then
- # Double space.
- sed -i '' 's/^$/d;G' $file
- # Insert a blank line on top, unless there's a shebang or DOCTYPE declaration.
- read line < $file;
- if ! [[ $line = ['#<']!* ]]; then
- sed -i '' '1{x;p;x}' $file
- fi
- # Remove excess whitespace after indents.
- sed -i '' 's/\([^ ]\) +/\1 /' $file
- echo "$file"
- fi
- done
Add Comment
Please, Sign In to add comment