Skip to content

Instantly share code, notes, and snippets.

@abraidotti
Created October 18, 2022 19:22
Show Gist options
  • Save abraidotti/47c15fc9a265d37964a27527f2da6d01 to your computer and use it in GitHub Desktop.
Save abraidotti/47c15fc9a265d37964a27527f2da6d01 to your computer and use it in GitHub Desktop.
bash one liners

remove last (empty) character of a file:

sed -i 's/.$//' file

ping every line in a file

cat file | xargs -i% ping -c 1 %

ping every line in a file and extract and save the IPs

cat DOMAINS.txt | xargs -i{} timeout 2 ping -q -c 2 {} | awk -F'[()]' '/PING/{print $2}' | tee IPs.txt

sort uniques in a file and replace the file

sort file | uniq >> file

find duplicates in two files

sort namelist1.txt namelist2.txt | uniq -d

colorful git log

git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

delete all merged but undeleted remote git branches

git branch --merged | grep -E -v "(main)" | xargs git branch -d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment