I have a recurring task of splitting a set of large (about 1-2 GiB each) gzipped Apache logfiles into several parts (say chunks of 500K lines). The final files should be gzipped again to limit the disk usage. On Linux I would normally do: The resulting files files will be named xaa, xab, xac, etc So I do: The…
How does a C compiler find that -lm is pointing to the file libm.a?
What’s .a files in C programming in linux ? Is it library file ? Here how compiler find that -lm is pointing to the file libm.a , and -lsocket as libsocket.a ? And if we add the header file to the program, Is it must we want to mention library while compiling ? Answer As Ignacio says, .a files are
How to sort files into folders by filetype on bash (with ‘file’ command)?
I have thousands of files without extensions after recovery (mostly pictures). I need to sort them into separate folders by filetype (folders must be created during sort process). I can determine filetype in linux using “file” command. Does somebody have bash script for it? For example: Initial di…
How to obtain total available disk space in Posix systems?
I’m writing a cross-platform application, and I need the total available disk space. For posix systems (Linux and Macos) I’m using statvfs. I created this C++ method: Unfortunately I’m getting quite strange values I can’t understand. For instance: f_blocks = 73242188 f_bsize = 1048576 …
How to view symbols in object files?
How can I view symbols in a .o file? nm does not work for me. I use g++/linux. Answer Instead of nm, you can use the powerful objdump. See the man page for details. Try objdump -t myfile or objdump -T myfile. With the -C flag you can also demangle C++ names, like nm does.
PostgreSQL without password prompt : .pgpass ignored
I’m trying to enable root (Ubuntu 8.04) to use psql command without password prompt (for scripting purpose). Everything worked fine with PostgreSQL 8.3, but I migrate to PostgreSQL 8.4 and the login without password doesn’t work anymore. I’ve a correct .pgpass file (the same used for 8.3), t…
Why does Glassfish appear to require much more memory in Linux than in Windows?
I’ve been tinkering with GlassFish 2.1.1 lately, on both an Ubuntu Linux box as well as a Windows XP one. Looking at the “java” processes representing asadmin, JavaDB server, and the GlassFish app server domain itself on Windows (using the Task Manager), they add up to just over 100 MB of me…
how to read files with spaces and special characters in their name?
i have lots of videos in my server and i use the following code to get the duration of the video and it works fine.. But i could not get the duration for the files which has a space or any special characters like ( ‘ # % etc… I cant rename the files as it is stored already and
How to check if Linux console screensaver has blanked screen
is there a way to check programmatically (via ioctl(), etc.) or by reading a file in /sys, /proc or /dev) whether the screen has been blanked by the Linux console screensaver? Thanks and best regards, Günter Answer You can parse the output of xset q with DISPLAY set, but it’s not pretty.
Delete the first five characters on any line of a text file in Linux with sed
I need a one-liner to remove the first five characters on any line of a text file. How can I do that with sed? Answer means replace (“s”, substitute) beginning-of-line then 5 characters (“.”) with nothing. There are more compact or flexible ways to write this using sed or cut.