Last active
October 24, 2025 17:02
-
-
Save monobot/bfe51e99a07948b8678f8c4eb0aa7949 to your computer and use it in GitHub Desktop.
bash: useful bash utilities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # my functions | |
| function mkcd { | |
| mkdir -p $1 && eval cd $1 | |
| } | |
| function totaldir { | |
| ls -la $1 | awk '{ sum += $5 } { num += 1} END { print num, "ficheros", sum / 1024 , "Kb" }' | |
| } | |
| function total () { | |
| find ./ -type f -name '*.'$1 -exec cat {} + | wc -l | |
| } | |
| upup(){ DEEP=$1; [ -z "${DEEP}" ] && { DEEP=1; }; for i in $(seq 1 ${DEEP}); do cd ../; done; } | |
| # python | |
| function mkmodule { | |
| mkdir -p $1 && eval cd $1 && touch __init__.py | |
| } | |
| function pyclean { | |
| echo "Cleaning python bitcodes ..." && | |
| find . -name "*.pyc" -delete && | |
| find . -name "*.pyo" -delete && | |
| find . -name "*.pyw" -delete && | |
| find . -name "__pycache__" -delete && | |
| echo "... Done!" | |
| } | |
| function extract () { | |
| if [ -f $1 ] ; then | |
| case $1 in | |
| *.tar.bz2) tar xvjf $1 ;; | |
| *.tar.gz) tar xvzf $1 ;; | |
| *.bz2) bunzip2 $1 ;; | |
| *.rar) unrar x $1 ;; | |
| *.gz) gunzip $1 ;; | |
| *.tar) tar xvf $1 ;; | |
| *.tbz2) tar xvjf $1 ;; | |
| *.tgz) tar xvzf $1 ;; | |
| *.zip) unzip $1 ;; | |
| *.Z) uncompress $1 ;; | |
| *.7z) 7z x $1 ;; | |
| *) echo "'$1' cant be uncompressed with >extract<" ;; | |
| esac | |
| else | |
| echo "'$1' unkonwn extension" | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
line 44:
cant->can’t