Skip to content

Instantly share code, notes, and snippets.

@stekan
stekan / wget-download-files.sh
Last active May 20, 2016 03:38
Download Files with wget
#!/bin/bash
INPUT=urls.txt
while read val
do
URL=`echo ${val}|awk '{ print $1 }'`
wget ${URL}
done < ${INPUT}
@stekan
stekan / wget-check-header.sh
Last active May 20, 2016 03:39
Check HTTP-Header with wget
#!/bin/bash
urls='urls.txt'
log='log.txt'
while read url; do
result=$(wget --server-response --spider --timeout=10 $url 2>&1)
echo "$result" >> "$log"
done < $urls
@stekan
stekan / imagemagick-thumbs-index.sh
Created May 20, 2016 03:40
Generate Thumbnail-Index with ImageMagick
#!/bin/bash
> index.html
[ -d thumbs ] || mkdir thumbs
for f in *.png; do
convert $f -strip -thumbnail 200x100 thumbs/$f
done
find -maxdepth 1 -name \*.png -exec echo "<a href=\"{}\"><img src=\"thumbs/{}\" border=\"0\" style=\"margin:10px;border:1px solid #ccc;\"></a>" \; | sort >> index.html
@stekan
stekan / imagemagick-resize-images.sh
Created August 2, 2016 07:19
Generate Images for srcset with ImageMagick
#!/bin/bash
## define image directory
DIR=.build/src/webroot/uploads
## define image sizes
sizes=(320 640 1280)
## imagemagick function
## convert $1(image) $2(width) $3(newname)
@stekan
stekan / copy-eml-date-dir.sh
Created August 7, 2017 18:04
Copy emails to directory year/month/day
#!/bin/bash
SRC=/path/to/eml/src
DEST=/path/to/eml/dest
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
cd "$SRC"
for file in $(find -type f -name "*.eml")
do
EMAILDATE=$(grep -m 1 "^Date: " < "$file" | sed -e "s/Date://g")
y=$(date --date="$EMAILDATE" +%Y)
@stekan
stekan / decrypt-gpg-email.sh
Created August 7, 2017 18:05
Find gpg email and decrypt
#!/bin/bash
SRC=/path/to/eml/src
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
cd "$SRC"
for file in $(find -type f -name "*.eml" -exec grep -l "BEGIN\ PGP\ MESSAGE" {} \; -print)
do
gpg --decrypt --batch --no-tty --output "$(echo $file|sed 's/\.[^.]*$//').decrypted.eml" "$file"
done
IFS=$SAVEIFS