Skip to content

Instantly share code, notes, and snippets.

@tracertea
tracertea / xargs:stop_xargs_execution
Created March 20, 2018 16:45
Stop xargs from performing further processing when event is triggered
seq 1 30 | xargs -I {} bash -c 'if [ "$0" == "10" ]; then exit 255; fi; echo $0' {}
@tracertea
tracertea / sed:multiple_replacements
Created March 20, 2018 16:37
perform multiple replacements in a single sed
| sed -e 's/:80//g; s/:443//g'
@tracertea
tracertea / javascript:rewrite_address_bar
Created September 14, 2016 13:56
Rewrite the contents of the address bar.
window.history.pushState("", "", '/login');
@tracertea
tracertea / sh:param_to_multiple_commands
Created September 8, 2015 18:38
Pass a parameter to multiple commands
find . -type f ! -name '*.strings' -exec sh -c 'strings $0 > $0.strings' {} \;
@tracertea
tracertea / xargs,sh:multi_param_commands
Created September 8, 2015 18:26
Run batch multi parameter commands
cat myFile.txt | xargs -I {} sh -c 'p=(`echo $0`); echo ${p[1]} ${p[0]}' {}
@tracertea
tracertea / find,rsync:copy_keep_directory_structure
Created July 7, 2015 21:12
Copy files maintaining directory structure
find . -type f -iname "*.java" -o -iname "*.cpp" -exec rsync -R {} /DESTINATION/PATH \;
@tracertea
tracertea / find:delete_empty_subdirectories
Last active August 29, 2015 14:24
delete all empty sub directoires
find . -type d -empty -delete
@tracertea
tracertea / fuser:kill_pid_associated_with_port
Created December 29, 2014 16:28
kill pid associated with port
fuser -k 8000/tcp
@tracertea
tracertea / fuser:port_to_pid
Created December 29, 2014 16:27
display the process id associated with a port
fuser 8000/tcp
@tracertea
tracertea / find,echo,plutil:plist_dump
Created October 30, 2014 16:16
display the contents of all plist files within a directory recursively OSX
find . -name "*.plist" -exec echo {} \; -exec plutil -p {} \;