Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Deleting files in Sage shell using pattern matching

I have a Sage project with includes some files ending in .sage and some ending in .py. So, I have also created a Makefile to preparse the Sage files, and inside my Makefile I have a clean command, which I want to delete all the files generated after the build process, but keep my own .py files. Therefore, I wrote something like this inside my Makefile:

clean:
    shopt -s extglob; 
    rm !(logger.py|utils.py|*.sage)

So, simply, when someone calls make clean I want it to delete all the .py and .pyc files generated after the make process, but keep the two .py files that are written by myself, and also keep all the Sage files. The problem is that it executes the first statement is executed successfully and it activates extended pattern matching. But then, the second state fails at (, it says that it got an unexpected character. To my knowledge, once the extended pattern matching is activated the above shown remove command should work. Any ideas what the problem might be and how to achieve what I want?

Deleting files in Sage shell using pattern matching

I have a Sage project with includes some files ending in .sage and some ending in .py. So, I have also created a Makefile to preparse the Sage files, and inside my Makefile I have a clean command, which I want to delete all the files generated after the build process, but keep my own .py files. Therefore, I wrote something like this inside my Makefile:

clean:
    shopt -s extglob; 
    rm !(logger.py|utils.py|*.sage)

So, simply, when someone calls make clean I want it to delete all the .py and .pyc files generated after the make process, but keep the two .py files that are written by myself, and also keep all the Sage files. The problem is that it executes the first statement is executed successfully and it activates extended pattern matching. But then, the second state fails at (, it says that it got an unexpected character. To my knowledge, once the extended pattern matching is activated the above shown remove command should work. Any ideas what the problem might be and how to achieve what I want?