Skip to content

Instantly share code, notes, and snippets.

Avatar

Martin Peters martinbpeters

View GitHub Profile
@martinbpeters
martinbpeters / File renaming
Created November 26, 2010 09:18
Simple file renaming using a loop in shell
View File renaming
#!/bin/sh
#
# Create a list of all txt files
# Loop over all files
# Extract name (split on '_')
# Copy file to new extension (text)
#
files=`ls -l *.txt | awk '{print $9}'`
@martinbpeters
martinbpeters / Percentage
Created November 26, 2010 10:17
Calculate a percentage using shell
View Percentage
#!/bin/sh
#
# Calculates a percentage
#
echo "scale=3; $1 / $2 * 100" | bc
@martinbpeters
martinbpeters / BashFor
Created November 26, 2010 10:19
Bash for loop
View BashFor
#!/bin/bash
t="1 2 3 4"
for i in ${t};
do
echo $i
done
@martinbpeters
martinbpeters / dateFormat.sh
Created November 26, 2010 10:21
Format date using shell
View dateFormat.sh
#!/bin/sh
d=(`date | tr ' ' ' '`)
echo "${d[1]}.${d[2]}.${d[5]}.${d[6]}"
@martinbpeters
martinbpeters / ColumnRemover.sh
Created November 26, 2010 10:22
Removes the second column from a file using shell
View ColumnRemover.sh
#!/bin/sh
cat $1 | awk '{ $2="";print}' >> $2
@martinbpeters
martinbpeters / stringReplace.sh
Created November 26, 2010 10:23
String replacement using shell
View stringReplace.sh
#!/bin/sh
sed "s/$1/$2/g" $3 > tmp; mv tmp $3
@martinbpeters
martinbpeters / toLower.sh
Created November 26, 2010 10:27
Convert text in file to lower case using shell
View toLower.sh
#!/bin/sh
cat $1 | tr '[A-Z]' '[a-z]' > $2
@martinbpeters
martinbpeters / toUpper.sh
Created November 26, 2010 10:28
Convert text in file to upper case using shell
View toUpper.sh
#!/bin/sh
: <<'COMMENTOUT'
Simple script to change the case of text within a file
COMMENTOUT
cat $1 | tr '[a-z]' '[A-Z]' > $2
@martinbpeters
martinbpeters / README.md
Last active December 11, 2015 10:58
Map of Ireland with Raphael
View README.md
@martinbpeters
martinbpeters / Electoral_Divisions_CSO_Generalised_100M.geojson
Created January 25, 2020 08:41
Ireland CSO EDs Generalised at 100M
View Electoral_Divisions_CSO_Generalised_100M.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.