/writing

Useful Unix Commands

Useful Unix and (Git) commands. Updated often.

  • Git reset one file to head
git checkout HEAD -- my-file.txt
  • Append to file with echo
echo "old_files/" >> .gitignore
  • Checking differences after copying
diff -rq --no-dereference /path/to/old/drive/ /path/to/new/drive/
  • Delete All Node Modules in a big folder with multiple sub dirs and node modules
find . -type d -name node_modules -prune
find . -type d -name node_modules -prune -exec rm -rf {} \;
  • Summary of new/missing files, and which files differ:
diff -arq folder1 folder2 --exclude=node_modules
  • Ignore node_modules folder everywhere
echo "node_modules/" >> .gitignore && git rm -r --cached node_modules ; git status
  • Recursively find and delete files with "text" in their names:
find -type f -name '*text*' -delete

Written with Mavié.

§

If you enjoyed reading this, subscribe to my newsletter!