Tips to using bash script

Append text at the beginning of files, example:

  1. The css or scss file imported from 3rd party, will put all the class at the root level, even if the import code is inside a class scope. That cause lots of issue, the simplest workaround is to append the class scope at all CSS file begin and end.
  • Append a class at the beginning:
1
find . -name "*.css" | xargs -I {} sed -i '1s/^/.myclass{\n/' {}
  • Append a text at the end of the end of the file
1
find . -name "*.css" -print0 | xargs -0 -I{} sh -c 'echo "\n}" >> "{}"'
  • Check the network port
1
netstat -tulpn