Skip to content

Instantly share code, notes, and snippets.

View dixonge's full-sized avatar

Glenn Dixon dixonge

View GitHub Profile
Afghanistan
Albania
Algeria
American Samoa
Andorra
Angola
Anguilla
Antarctica
Antigua and Barbuda
Argentina
@dixonge
dixonge / USStatesAbbreviated
Created May 6, 2014 22:33
Two-letter Abbreviated List of U.S. States
AL
AK
AZ
AR
CA
CO
CT
DE
FL
GA

Keybase proof

I hereby claim:

  • I am dixonge on github.
  • I am dixonge (https://keybase.io/dixonge) on keybase.
  • I have a public key ASAtl9aGQlva6o-RX419jFu3dw4qs0adI3Hj9MPTxLB7cAo

To claim this, I am signing this object:

grep -rwl “search-string” /path/to/search/dir
@dixonge
dixonge / Find+SED-Search-Replace-All-Files-All-Subfolders
Last active April 2, 2020 16:15
Use find and sed to search/replace in all files in all subdirectories
find ./ -type f -exec sed -i -e 's/find-this/replace-with-this/g' {} \;
@dixonge
dixonge / Match-line-search-replace-multiple-characters-all-files
Created April 2, 2020 16:17
Match line and do a search/replace for multiple characters on all files
sudo sed -i '/match:/s/to-replace/replace-with/g' * 

@dixonge
dixonge / Make-Move.sh
Created April 2, 2020 16:21
Make a folder for each file, then move files to their matching folder. If you need to rename the file, add that at the end of the mv command line
#!/bin/bash
dir="/somedir/" for i in "$dir"*;
do if [ -f "$i" ];
then filename="${i%%.*}" if [ ! -d "$filename" ];
then sudo mkdir "$filename" fi sudo mv "$i" "$filename" fi
done
@dixonge
dixonge / Add-text-to-beginning-all-files-in-folder
Created April 2, 2020 16:23
Add a line of text to the beginning of all files in a folder
find ./ -type f -exec sed -i '1s/^/ \n/' {} \; 

@dixonge
dixonge / Delete-lines-after-pattern-match-all-files-in-folder
Created April 2, 2020 16:24
Delete lines *after* a pattern match in all files in a folder
find ./ -type f -exec sed -e '/pattern/{n;N;N;N;N;d}' {} \; 

@dixonge
dixonge / Delete-line-if-matches-pattern-all-files-in-folder
Created April 2, 2020 16:25
Delete a line if it matches a pattern in all files in a folder
sudo find ./ -type f -exec sed -i '/pattern-to-match/d' {} \;