måndag 2 mars 2015

linux - bash remove everything in file betwen char ( and char )

Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. clear
  2.  
  3. echo "Before:"
  4. echo "Gem actionmailer-4.2.0"
  5.   echo "actionpack (= 4.2.0)"
  6.   echo "actionview (= 4.2.0)"
  7.   echo "activejob (= 4.2.0)"
  8.   echo "mail (>= 2.5.4, ~> 2.5)"
  9.   echo "rails-dom-testing (>= 1.0.5, ~> 1.0)"
  10.  
  11. gem dependency > dependsgem.txt
  12. echo '(F/.M/d h)' | sed 's/(.*)//' dependsgem.txt > dependsgem1.txt
  13. sed -e '/^[A-Z]/d' dependsgem1.txt > dependsgem2.txt
  14. sed -e 's/^[ \t]*//' dependsgem2.txt > dependsgem3.txt
  15. sed '/^$/d' dependsgem3.txt > dependsgem4.txt
  16. sudo perl -lane 'print "@F" if @F = grep !$seen{$_}++, @F' < dependsgem4.txt > dependsgem5.txt
  17. ls -1 | awk 'ORS=" "' dependsgem5.txt > dependsgem6.txt
  18. fold -s dependsgem6.txt > dependsgem7.txt
  19. while read LINE;do LARGE="sudo gem install $LINE";echo $LARGE>>dependsgem.sh;done<dependsgem7.txt
  20. clear
  21.  
  22. echo "Make so .sh can run"
  23. sudo chmod u+x dependsgem.sh
  24.  
  25. echo "Clean - delete *.txt files"
  26. sudo rm dependsgem1.txt && rm dependsgem2.txt && rm dependsgem3.txt && rm dependsgem4.txt
  27. sudo rm dependsgem5.txt && rm dependsgem6.txt && dependsgem7.txt
  28. echo "dependsgem.sh created"
  29. echo "sudo ./dependsgem.sh to run"
  30.  
  31. echo "After:"
  32. echo "sudo gem install rake hoe actionpack actionview activejob mail rails-dom-testing activemodel"
  33. echo "sudo gem install activesupport rack rack-test rails-html-sanitizer builder erubis globalid arel"
  34. echo "sudo gem install i18n json minitest thread_safe tzinfo launchy rspec rspec-its ansi detroit qed"
  35. echo "sudo gem install ae ergo indexer lemon mast bundler thor rdoc cabin bcat childprocess cucumber"
  36. echo "sudo gem install cucumber-pro fuubar kramdown rspec-expectations rubocop coderay haml nokogiri"
Skicka en kommentar