Skip to content

Instantly share code, notes, and snippets.

View sodonnell's full-sized avatar

Sean O'Donnell sodonnell

View GitHub Profile
@sodonnell
sodonnell / using find and perl to replace strings in a directory tree.
Created February 27, 2018 18:04
Using find and perl to replace strings in (all) .php files within a directory tree.
find ./ *.php -exec perl -pi -e 's/\/old\/tree\/path/\/new\/path\/tree/' {} \;
@sodonnell
sodonnell / sed-replace.sh
Last active February 21, 2018 20:29
sed - string replacement in files
# replace 'http:' w/ 'https:' in all files within the current directory.
sed -i 's/http:/https:/g' ./*
@sodonnell
sodonnell / convert.sh
Created February 8, 2018 19:04
Resize an image and constrain the image proportionately to a specified width, using ImageMagick (convert) from the command line.
#!/usr/bin/env bash
#
# The gist example here does not perform any sanity or error checking. It's just a gist.
#
# example: resize an image file to 150px width...
# ./convert.sh example.jpg 150
#
$FILENAME=$1
$WIDTH=$2
#!/usr/bin/env bash
echo -e "Listing "established" network connections:\n"
netstat -punt | grep -i "udp\|tcp" | awk {'print $4"\t"$1 '} | sed s/.*://
#!/usr/bin/env bash
for i in `echo $PATH | sed 's/\:/\n/g'`; do ls -a $i; done
#!/usr/bin/env bash
echo "Total # of files available within your executable PATH: "
for i in `echo $PATH | sed 's/\:/\n/g'`; do ls -a $i; done | wc -l