Last active
January 27, 2021 16:36
-
-
Save orjanv/ebe88b8ec4b1086f611e1cb1c151c1f2 to your computer and use it in GitHub Desktop.
my short but growing list of bash one-liners i find useful
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
# Print specific line in file with sed | |
sed -n '07p' filename | |
# print line in file matching weeknumber | |
sed -n ''$(date +%V)'p' filename | |
# remove blank lines | |
sed '/^\s*$/d' | |
# print longest line in file | |
cat filename|awk '{print length, $0}'|sort -nr|head -1 | |
# Scan network for active hosts | |
nmap -sP 10.0.0.0/24 | |
# Same as above, but keep only addresses and sort them | |
nmap -sP 192.168.3.0/24 | grep report | cut -d' ' -f5,6 | sort | |
# Scan for open ports (require root) | |
sudo nmap -sS -O 10.0.0.249 | |
# Replace spaces in file names | |
find -name "* *" -type f | rename 's/ /_/g' | |
# Flip a video 90 degrees clockwise | |
avconv -i in.mp4 -vf "transpose=1" -strict -2 out.mp4 | |
# calculate n weeks from now | |
date -d 'now + n weeks' | |
# Calculate n weeks from any date | |
date -d 'Aug 4 + n weeks' | |
# Extract a specific string from all links in a webpage using curl, grep and sed | |
curl "http://www.gutenberg.org/wiki/Adventure_(Bookshelf)" | grep "www.gutenberg.org/ebooks/" | sed 's/.*ebooks\///' | sed 's/" class=.*//' > gutenberg-adventure-bookids.txt | |
# convert a video to gif using ffmpeg and gifsicle | |
ffmpeg -i in.mov -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > out.gif | |
# Run one command through ssh connection and exit by simply adding a trailing command | |
ssh user@host command | |
# Resize all .png-images | |
for f in *.png; do convert $f -resize 1000x900 1000px_$f; done | |
# Create a video from a set of images | |
ffmpeg -pattern_type glob -i '*.jpg' -pix_fmt yuv420p out.mp4 | |
# Make a collage of images with five columns and fill automatically numbers of rows | |
montage -geometry +0+0 -tile 5x *.jpg result.jpg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment