Advertisement
adamchilcott

sanitiseConfiguration.sh

Mar 9th, 2018
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.57 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. ##############################
  4. # Configuration File Sanitiser
  5. ##############################
  6.  
  7. sed -ri -e '/[[:blank:]]*#.*$/d ;/^[[:blank:]]*$/d ;s/[[:blank:]]*$// ;s/^[[:blank:]]*// ;s/[[:blank:]]*=[[:blank:]]*/=/' <file> && sort -fuo <file>
  8.  
  9. #############
  10. # START NOTES
  11. #############
  12.  
  13. ## in config files that have the form of key = value and uses # for comments,
  14. ## this little sed removes trailing and preceding whitespaces,
  15. ## deletes empty lines and removes comment lines.After, it sorts the file :
  16.  
  17. ###########
  18. # END NOTES
  19. ###########
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement