linux

Linux shell script to count occurance of char sequence in a text file?

I have a a large text file (over 70mb) and need to count the number of times a character sequence occurs in the file. I can find plenty of scripts to do this, but NONE OF THEM take in to account that a sequence can start and finish on different lines. For the sake of efficiency (I actually have way more than 1 file I am processing), I ca...

Widget Transparency in PyGTK?

What is the best way to have transparency of specific widgets in a PyGTK application? I do not want to use themes because the transparency of each of the widgets will be changing through animation. The only thing I can find is to use cairo to draw widgets with an Alpha, but I can't figure out how to do this. Is there perhaps a better wa...

Avoid linking to libstdc++

I'm working on an embedded project that currently uses C in Linux and uClibc. We're interested in moving it to C++, but I don't want the overhead associated with linking in libstdc++. My impression is that this is possible provided we don't use anything from STL, such as iostream or vector. How does one direct g++ to compile without li...

Difference between statvfs() and statfs() system calls?

Why do the statfs() and statvfs() calls both exist when they're so similar? Under what circumstances would I prefer one over the other? ...

What's a decent events library for non-GUI applications under *nix? (C++)

First, I'm using Qt at the moment. However, I want the program eventually able to run without a GUI environment, leaving the graphical aspects for configuration mainly. The program makes hefty use of Qt timers and signals/slots, partially for QtScript. So if I want to make it non-GUI operable, hopefully parts of Qt can run without a GUI ...

Is there a grep or shell script that uses a regex to change filenames?

How can I recursively change xxx-xxx_[a-zA-Z]+_\d+_(\d+)\.jpg into $1.jpg? ...

Convert files names into integers.

So I have: 01.jpg 02.jpg 3.jpg 4.jpg 05.jpg and want to make them all like below using a shell script or a command on linux 1.jpg 2.jpg 3.jpg 4.jpg 5.jpg ...

How can I delete a newline if it is the last character in a file?

I have some files that I'd like to delete the last newline if it is the last character in a file. 'od -c' shows me that the command I run does write the file with a trailing new line: 0013600 n t > \n I've tried a few tricks with sed but the best I could think of isn't doing the trick: sed -e '$s/\(.*\)\n$/\1/' abc Any ideas...

Linux optimistic malloc: will new always throw when out of memory?

I have been reading about out of memory conditions on Linux, and the following paragraph from the man pages got me thinking: By default, Linux follows an optimistic memory allocation strategy. This means that when malloc() returns non-NULL there is no guarantee that the memory really is available. This is a really bad bug. In case it...

SSH on Linux: Disabling host key checking for hosts on local subnet (known_hosts)

I work on a network where the systems at an ip address will change frequently. They are moved on and off the workbench and DHCP determines the IP they get. It doesn't seem straightforward how to disable host key caching/checking so that I don't have to edit ~/.ssh/known_hosts every time I need to connect to a system. I don't care ab...

PYTHONPATH environment variable...how do I make every subdirectory afterwards?

I currently do this: PYTHONPATH=/home/$USER:/home/$USER/respository:/home/$USER/repository/python-stuff How can I make it so that the PYTHONPATH can include everything subdirectory? PYTHONPATH = /home/$USER/....and-all-subdirectories ...

How to prevent GCC from passing in default flags?

I am trying to cross-compile linux for an ARM architecture. The host is an X86 machine running ubuntu-jaunty. I downloaded a cross-compile toolchain for ARM from http://ftp.arm.linux.org.uk/pub/armlinux/toolchain/. I downloaded the 2.95.3 version of the toolchain. The problem I am having is that GCC is passing in some default flags by ...

Signal handler for SIGALRM does not work even if resetting in the handler

The example code of section 10.6, the expected result is: after several iterations, the static structure used by getpwnam will be corrupted, and the program will terminate with SIGSEGV signal. But on my platform, Fedora 11, gcc (GCC) 4.4.0, the result is [Langzi@Freedom apue]$ ./corrupt in sig_alarm I can see the output from ...

How can I synchronized two process accessing on the same resources?

I have two processes which access to the same physical memory(GPIO data addr). So how can I have synchronized between these apps? I understand that we have some kind of locking mechanism such as mutex and semaphore, so which method is the fastest? Thank for your help, -nm ...

Problem with getting information of currently configured network interfaces on Linux

I am encountering a problem with string formatting while trying to get only the names of currently configured network interfaces on a Linux Machine. 1. <?php 2. $temp = shell_exec("/sbin/ifconfig | cut -b 1-10"); 3. echo $temp; //Outputs: eth0 lo 4. $arr = explode(" ",$temp); 5. echo "First Location:".$arr[0]; ...

Where is stdbool.h?

I want to find the _Bool definition on my system, so for systems where it's missing I can implement it. I've seen various definitions for it here and on other sites, but wanted to check on the system for the definitive definition. Slight problem, in that I can't find where _Bool is defined or even stdbool.h mussys@debmus:~$ find /usr/i...

HTTP request builders for GNU/Linux?

I’m looking for tools for interactively inspecting HTTP servers by manually constructing requests (and viewing responses), under GNU/Linux. Something that would let me quickly specify standard header fields, make a form request body, etc. (netcat doesn’t really excel at this.) Any suggestions? ...

Platform independant resource management

Hi, I'm looking for a way to embed text files in my binaries (like windows resource system). I need something thats also platform independant (works in windows and linux). I found qt resource management to be what I need but Im not keen on my app depending on qt for this alone. I also found this tool at http://www.taniwha.com/~paul/res/...

Codeblocks on fedora 9 : Cannot build the C project

I have a simple C console application named Test. But when I build, it says Test - Debug uses a invalid compiler Nothing to do What is the error? The test.cbp(project file) contents are as follows: <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <CodeBlocks_project_file> <FileVersion major="1" minor="6" /> <Pr...

How can I calculate an md5 checksum of a directory?

I need to calculate a summary md5 checksum for all files of a particular type ( *.py for example ) placed under a directory and all subdirectories. What is the best way to do that? Thanks. The proposed solutions are very nice, but this is not exactly what I need. I'm looking for a solution to get a single SUMMARY checksum which will uni...