Skip to content

Instantly share code, notes, and snippets.

@luzpaz
Last active March 10, 2023 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luzpaz/cdd9a93a883e5f2ec4f794b601afcd89 to your computer and use it in GitHub Desktop.
Save luzpaz/cdd9a93a883e5f2ec4f794b601afcd89 to your computer and use it in GitHub Desktop.
CLI gems
grep -R (recurse through subdirectories)
grep -i (Case insensitive)
grep -e (extended regex, allows for regex modifiers)
grep -l (only returns file name)
grep -Rle 'aligne\b' | xargs sed -i 's/aligne\b/align/'g
# search for the string 'aligne' (don't returns strings like 'aligned')
# pass all files that have said string to xargs which quickly processes
# sed (with the -i flag to process in place)
How to cat and sed together?
https://unix.stackexchange.com/questions/422005/how-to-cat-and-sed-together
# Copying commits from other repos
## This will print the diff,
## then grep all lines that start with '+' and a letter or number (needs other conditions as well
## the truncates the '+' of the beginning of the result
## copies everything to the buffer
git show | grep '^+[a-zA-Z0-9]' | cut -c 2- | pbcopy
## append the last 5 commits with the same regex, to some other file
git show -n 5 | grep '^+[a-zA-Z0-9]' | cut -c 2- >>
# find all trailing whitespaces in freecad
find . -name "*" -not -name "*.ts" -not -name "*.qm" -not -name "*.po" -not -name "*.fcstd" -not -name "*.FCStd" -not -name "*.brep" -not -name "*.pdf" -not -name "*.ttf" -not -name "*.svg" -not -name "*.png" -not -name "*.sif" -not -name "*.frd" -not -name "*.jt" -not -name "*.inp" -not -name "*.stp" -not -name "*.dxf" -not -name "*.zip" -not -name "*.zip" -not -type d -not -path "./src/3rdParty/*" -not -path "./src/Gui/Quarter/*" -not -path "./src/Mod/AddonManager/Resources/licenses/*" -not -path "./src/Mod/Path/libarea/*" -not -path "./src/Mod/Robot/*" -not -path "./src/WindowsInstaller/*" -not -path "./src/Mod/Import/App/SCL/*" -not -path "./src/Mod/Import/App/automotive_design.py" -not -path "./src/Base/StackWalker.h" | xargs grep -E ".* +$"
# Find header copyright without year in correct order
.*Copyright \(c\) [^\d\d\d\d]
# codespell with orbitcowboys dictionary
codespell -D dictionary_all.txt -I ./.github/codespellignore -q 3 -S *.po,*ts,./src/3rdParty,./dictionary_all.txt,./src/WindowsInstaller,./src/Mod/Robot/App/kdl_cp,./src/Mod/Import/App/ifc4.py,./src/Mod/Import/App/ifc2x3.py,./src/Mod/Import/App/automotive_design.py,./src/Mod/Import/App/SCL,./src/App/lex.ExpressionParser.c,./src/Base/QuantityLexer.c,./src/Base/StackWalker.cpp -L aa,addon,ae,aes,amin,ang,anobject,assertin,att,attribs,aview,bbegin,bblock,byteorder,bv,cas,ccomment,comf,commandline,connecticon,clu,cvs,dat,datafile,dialogbox,documentt,dof,eend,eerror,eg,errorstring,estart,ffield,ffirst,fil,fred,guid,gut,heightend,iff,ii,iindex,iinterface,iitem,il,im,indice,indx,innerfaces,irow,iss,itt,lama,llayout,llist,layouth,lo,los,materiallist,mmode,modulus,mpoint,nol,nul,nullpointer,originat,parens,poisson,popup,popups,postprocessor,postprocessors,pparent,ppath,ppoint,ppoints,principal,prov,removee,ro,sels,setf,sinc,sstring,sstyles,statics,stran,storey,storeys,svalues,symbolfile,technic,tempset,tok,tol,tot,typ,typs,uint,und,unittestsuv,uv,vals,vvertices,wo,ww,work-around,re-use,multi-dimensional | more
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment