Skip to content

Instantly share code, notes, and snippets.

@pipitone
Last active December 30, 2015 10:19
Show Gist options
  • Save pipitone/7815367 to your computer and use it in GitHub Desktop.
Save pipitone/7815367 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Edits a minc header, swapping occurances of two strings
#
# (e.g. useful if you're trying to swap x/y dimension names)
minc=$1
attr1=$2
attr2=$3
tmpattr=att$RANDOM
if [ $# -ne 3 ]; then
echo "Swaps strings in a minc header"
echo
echo "Usage: mincswap <input.mnc> <string> <string>"
echo
echo "NOTE: this script happily clobbers your input files without checking"
echo "that these strings exist, and don't overlap, etc."
echo
exit
fi
mincedit $minc "sed -i -e s/$attr1/$tmpattr/g -e s/$attr2/$attr1/g -e s/$tmpattr/$attr2/g"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment