drosofff
8/29/2016 - 9:30 AM

a sample of use of grep and xargs to search/edit files in batch

a sample of use of grep and xargs to search/edit files in batch

  526  grep -R "ansible-artimed" .
  527  grep -R -i "ansible-artimed" .
  528  grep -R "artimed" .
  529  grep -R -i "ansible-artimed" .
  530  grep -R -i "ansible-artimed" --exclude .git .
  531  grep -R -i "ansible-artimed" --exclude-dir=.git .
  532  grep -R -i "ansible-artimed" --exclude-dir=.git -l .
  533  grep -R -i "ansible-artimed" --exclude-dir=.git -l . | head -n 12
  534  grep -R -i "ansible-artimed" --exclude-dir=.git -l . | head -n 12 | xargs sed -i .bak s/ansible-artimed/GalaxyKickStart/g
  535  ll | grep bak
  536  grep -R -i "ansible-artimed" --exclude-dir=.git -l . | head -n 12 | xargs -0 sed -i .bak s/ansible-artimed/GalaxyKickStart/g
  537  grep -R -i "ansible-artimed" --exclude-dir=.git -l . | head -n 12
  538  grep -R -i "ansible-artimed" --exclude-dir=.git -l . | head -n 12 | xargs -I{} sed -i .bak s/ansible-artimed/GalaxyKickStart/g "{}"
  539  grep -R -i "ansible-artimed" --exclude-dir=.git -l . | head -n 12
  540  git diff
  541  git status
  542  ll
  543  find . -name .bak
  544  find . -name *.bak
  545  find . *.bak
  546  find . -name "*.bak"
  547  find . -name "*.bak" | xargs -I{} rm "{}"