Skip to content

Instantly share code, notes, and snippets.

View sodonnell's full-sized avatar

Sean O'Donnell sodonnell

  • Los Angeles, CA
View GitHub Profile
#!/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
#!/usr/bin/env bash
for i in `echo $PATH | sed 's/\:/\n/g'`; do ls -a $i; done
#!/usr/bin/env bash
echo -e "Listing "established" network connections:\n"
netstat -punt | grep -i "udp\|tcp" | awk {'print $4"\t"$1 '} | sed s/.*://
@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
@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 / 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 / Replacing strings in a single file using Perl
Created February 27, 2018 18:05
Replacing strings in a single file using Perl
sudo perl -pi -e 's/Defaults requiretty//' /etc/sudoers
@sodonnell
sodonnell / nmap-lan-httpd
Last active June 26, 2018 22:42
nmap - Subnet sweep of machines with open HTTP/S and common proxy ports
# This assumes you're using the 192.168.0. class-C subnet.
# Modify according to your specific subnet.
# default http/https ports
nmap 192.168.0.0/24 -P0 -p 80,443 | grep -B 4 "open"
# commonly used http, proxy and other related ports
nmap 192.168.0.0/24 -P0 -p 80,443,8000,8080,9000,9090 | grep -B 4 "open"
@sodonnell
sodonnell / mount_iso.sh
Created April 18, 2018 15:38
Mount an ISO Disk Image to your file system.
#!/bin/bash
sudo mkdir /mnt/iso
sudo mount -o loop disk.image.iso /mnt/iso