Skip to content

Instantly share code, notes, and snippets.

View paulboardman's full-sized avatar

Paul Boardman paulboardman

View GitHub Profile
dta <- read.delim('some stuff', as.is=T)
lm1 <- lm(dta$blorg ~ dta$wibble)
montage -geometry +2+2 -tile 2x -shadow <filenames>+ merged_file.png
@paulboardman
paulboardman / gist:5354789
Created April 10, 2013 13:49
Find command to locate files with no group write permissions. Execute ls -lh on the file to show permissions.
find . ! -perm /g+r -exec ls -lh {} \;
@paulboardman
paulboardman / gist:5354835
Created April 10, 2013 13:52
Find command to find files that are not group read or (inclusive) writeable and updates their permissions.
find . ! -perm /g+rw -exec chmod g+rw {} \;
@paulboardman
paulboardman / gist:5707151
Created June 4, 2013 16:02
Simple find commandline example.
find . -name "*.csv" -exec ls -ls {} \;
@paulboardman
paulboardman / gist:5707161
Last active December 18, 2015 01:58
'find' command with multiple filename patterns. The -name arguments must be grouped for this to work as expected.
find . \( -name "*.csv" -or -name "*.tsv" \) -exec ls -lh {} \;
@paulboardman
paulboardman / gist:5707271
Created June 4, 2013 16:18
Find and delete empty files (using 'find')
find . -empty -delete
@paulboardman
paulboardman / find_examples.sh
Created June 5, 2013 13:01
Example of a find command that doesn't work as expected. The 'ls' command is only executed on the *.tsv files due to the way the expression is evaluated: from left to right with the implicit '-and' between the second '-name' and '-exec' exec having higher precedence than the '-or' between the two '-name' tests..
find . -name "*.csv" -or -name "*.tsv" -exec ls -lh {} \;
# this is actually executed as:
find . -name "*.csv" -or \( -name "*.tsv" -exec ls -lh {} \; \)
# when what you wanted was:
find . \( -name "*.csv" -or -name "*.tsv" \) -exec ls -lh {} \;
# the general recommendation is to use xargs inplace of the -exec action
find . -name "*.csv" -or -name "*.tsv" | xargs ls -lh
@paulboardman
paulboardman / gist:5714993
Created June 5, 2013 15:53
find command for finding and removing empty directories/files whilst ignoring certain dirs (in this case the knime tree).
# first print out the files/dirs
find . -path "*/knime/*" -prune -or -empty -print
# if you're happy with the list then we can get rid of them
find . -path "*/knime/*" -prune -or -empty -print | xargs rm -r
@paulboardman
paulboardman / gist:5830333
Created June 21, 2013 10:26
Example use of the $'...' quoting construct in bash.
echo -e "second:first" |\
cut -d: --output-delimiter=$'\t' -f 1,2 |\
awk -F $'\t' 'BEGIN{OFS=FS}{print $2,$1}'
# outputs: "first<tab>second"