Last active
December 30, 2015 10:19
-
-
Save pipitone/7815367 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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