Skip to content

Instantly share code, notes, and snippets.

@hdznrrd
Created December 6, 2018 15:55
Show Gist options
  • Save hdznrrd/afbfd12506d8a8b447533ec5b73494ee to your computer and use it in GitHub Desktop.
Save hdznrrd/afbfd12506d8a8b447533ec5b73494ee to your computer and use it in GitHub Desktop.
#!/bin/bash
# hadez@infuanfu.de
# fix jscut.org gcode comment format so it works with uccnc
if [ ! -e "$1" ]; then
echo "no file given, exiting"
exit 1
fi
if [ "$2" != "" ]; then
echo "only single file parameter allowed, exiting"
exit 1
fi
dos2unix "$1"
tmp=$(mktemp)
cat "$1" | perl -pe 'm/^(.*?)(?:;(.*))?$/; $_="$1$/"; $_="$1 ($2)$/" if defined $2;' > "$tmp"
mv "$tmp" "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment