Sign In

    Enjoy FOSSwire's content? Have it delivered! Subscribe

    Quick Command Line Tip - Recursively Delete Files of a Certain Type

    Applications can create a lot of temporary files sometimes, and these files aren't always cleaned up automatically.

    An example of this is when you run Python applications. Particularly if you're a Python developer, your source code directories stack up with a .pyc version of each file, which is the cached compiled copy of the script.

    To clean up (especially if you're going to do a source commit or an upload somewhere to extend that example) files of a certain file extension, you can use this command line snippet:

    $ find . -name "*.ext" -exec rm '{}' ';'

    Obviously, replace *.ext with the pattern that you want to delete.

    I shouldn't need to say this, but use this with caution. Make sure you're not accidentally going to delete something useful that matches the pattern you enter, and always keep backups yada yada. Tread carefully when batch deleting.


    Debugging with Nemiver

    You're writing some C code that you just managed to compile. You are able to get it to build without errors, and you're ready to run. But then, something disastrous happens:

    $ gcc main.c -o out
    $ ./out
    Segmentation fault

    Great. Your application dies without so much as an explanation as to why. Nobody likes to debug code, but it has to be done at some point. If you compiled with the -g flag to gcc or g++, your program will have some debugging information included that special programs, like gdb, can use to assist you in solving the problem.

    Nemiver is a graphical tool that can be used to take advantage of debugging information that uses gdb as a backend. It provides all of the features that the terminal-based gdb provides, but in a more sophisticated GUI interface that follows the code as it is executed. This means you can run code line-by-line, add breakpoints, view pointers, variables, memory registers, and see the call stack. In addition, you are also able to attach to a program over a network; so if your web server application goes down, you can run it over-the-wire with Nemiver to try to solve the problem.

    Nemiver

    To give it a test run, let's try it out with some code that segfaults in a normal run. First, after loading up the file, we'll run it line-by-line to find the problem.

    Nemiver Line-By-Line

    Okay, so the segmentation fault appears:

    Nemiver Segfault

    It's at a line where an object is attempting to "lock" another object. Let's take a look at the variables:

    Nemiver Variable View

    Yep, there's the problem. Surface isn't actually pointing to any real variable, hence the 0x1. You may also see 0x0, it also means a pointer is not assigned correctly.

    Nemiver is a great tool to use for code problems as in the example above. It does have a few usability quirks; it can take a lot of clicks to get from one point to the next. Session saving in 0.5.2 also has its problems and usually results in an error or two. But 90% of the time, Nemiver works like a charm and is a nice breath of fresh air from trying to debug from a terminal. If you like to program in C or C++ and constantly have debugging errors or just want to try something new, Nemiver is a must.


    Ubuntu Cheat Sheet

    With the Ubuntu 8.04 release a few days away, there comes a time when one needs an end-all reference to the system. The time is now, and if you're an Ubuntu user and liked the original cheat sheet, then do we have a surprise for you:

    Ubuntu Cheat Sheet (image)

    Click the preview above to download your PDF copy. This sheet is free to modify and redistribute for your own needs; we just ask that you keep the FOSSwire logo on the page. License: Creative Commons Attribution-Share Alike 3.0 Unported.

    If you haven't seen the previous sheet or would like one with more general Linux and Unix commands, see the original.

    Translations:

    As always, we're open to more translations and fixes. Enjoy!


    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6