Skip to content

Instantly share code, notes, and snippets.

@hightemp
Last active October 22, 2023 12:10
Show Gist options
  • Save hightemp/b5590da5c1fc3bb7cba28ca5659cd009 to your computer and use it in GitHub Desktop.
Save hightemp/b5590da5c1fc3bb7cba28ca5659cd009 to your computer and use it in GitHub Desktop.
Bash snippets

Bash snippets

Get size of files of current directory with mask

du -c `find . -maxdepth 1 -name '*.php'` | tail -1

Count lines in files with mask

find . -maxdepth 1 -name '*.php' -print | xargs wc -l

Exclude path from search by find

find ./ -name '*.*' -not -path "./pathname/*"

Rename files by mask, add extension to files

rename 's/(.*)/$1.jpg/' *

Recursively output list of files with extensions

ls -1 -- **/+(*.jpg|*.gif|*.png)

Use find with multiple extensions

Method 1

find . -type f \( -name "*.shtml" -or -name "*.css" \)

Method 2

find -type f -regex ".*/.*\.\(shtml\|css\)"

C++ calls graph

clang++ -S -emit-llvm main.cpp -o - | opt -analyze -dot-callgraph
dot -Tpng -ocallgraph.png callgraph.dot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment