Adding or Removing line numbers to G Code files

14 Mar 2012 17:14 #18601 by ArcEye

Prompted by a discussion in another thread i thought I would publish my solution to this.

There are quite a few good CAM programs and code generators which insist upon having linenumbers at every line.

LinucCNC will run them, but they are completely superfluous and often very confusing.

The below will strip them or add them, note the different invocations for the 2 commands.

## inserts or removes line numbers at start of each line
## usage: linenumbers insert oldfile newfile
##        linenumbers remove filename  (overwrites so perform on a copy)

case $1 in
    insert )    exec < $2
                e=" "

                while read LINE ; do
                    echo $c >> $3
                done ;;
    remove )    sed -i "s/^ *N[0-9]* //g" $2 ;;

exit 0


Please Log in or Create an account to join the conversation.

Time to create page: 0.121 seconds
Powered by Kunena Forum