unix

Lightweight process execution timer for Windows

Is there a lightweight process execution timer like Unix's time included with Windows? Sometimes I just want a rough estimate, without having to get out a real profiler. While I could roll my own, I would prefer to use an existing solution. ...

shell script templates

what would be your suggestions for a good bash/ksh script template to use as a standard for all newly created scripts? I usually start (after #! line) with a commented-out header with a filename, synopsis, usage, return values, author(s), changelog and would fit into 80-char lines. all documentation lines I start with double-hash symbo...

Is there is a software caching API out there?

Hi all, I'm looking for an API or an application that can cache data from a file or database. My idea is that I have an application that reads a database, but the access to database is sequential and it is on a disk. What I basically want to do is get the data from cache first and then if it doesn't exist in cache, then hit the databas...

C/C++ environment initialization

A co-worker just asked me if it was safe to use getenv() in static initializers, that is, before main(). I looked in Stevens, and in the Posix Programmer's Guide, and the best I can find is An array of strings called the enviroment is made available when the process begins. This array is pointed to by the external variable environ,...

Counting no. of Delimiter in a row in a File in Unix

I have a file 'records.txt' which contains over 200,000 records. Each record is on a separate line and has multiple fields separated by a delimiter '|'. Each row should have 35 fields, but the problem is one of these rows has <>35 fields, i.e. <>35 '|' characters. Can someone please suggest a way in Unix, by which I can identify the r...

How do you uninstall in *nix?

One of the things I still can't wrap my head around is rules of thumb to uninstall programs in *nix environments. Most of the time I'm happy to let the sleeping dogs lie and not uninstall software that I no longer need. But from time to time I end up with several Apaches, svn, etc. So far here's what I know about dealing with this: 1)...

How can I rotate log files monthly using Perl?

In Unix, I need to be able to archive log files into monthly folders, labelled accordingly. How do I do this in Perl? ...

Simple unix command, what is the {} and \; for

With this set of commands, what are the {} and \; characters for? find . -name '*.clj' -exec grep -r resources {} \; ...

Why does my c program not free memory as it should?

I have made a program in c and wanted to see, how much memory it uses and noticed, that the memory usage grows while normally using it (at launch time it uses about 250k and now it's at 1.5mb). afaik, I freed all the unused memory and after some time hours, the app uses less memory. Could it be possible, that the freed memory just goes f...

What's an easy way to read random line from a file in Unix command line?

What's an easy way to read random line from a file in Unix command line? ...

How to easily and simply, schedule a cron job in PHP -- Rails has BackgroundRB.. Thanks for your help!

How to easily and simply, schedule a cron job in PHP -- Rails has BackgroundRB.. Thanks for your help! ...

Bash script to receive and repass quoted parameters

I'm trying to get quoted parameters of a bash script to safely be received by a nested script. Any ideas? test.sh #!/bin/bash echo $* bash myecho.sh $* myecho.sh #!/bin/bash echo $1 echo $2 echo $3 echo $4 Sample: bash test.sh aaa bbb '"ccc ddd"' Result: aaa bbb "ccc ddd" aaa bbb "ccc ddd" Wanted result aaa bbb "ccc ddd...

egrep search for whitespace

I'm trying to use egrep w/ a regex pattern to match whitespace. I've used RegEx w/ perl and C# before and they both support the patter \s to search for whitespace. egrep (or at least the version I'm using) does not seem to support this pattern. In a few articles online I've come across a shorthand [[:space:]], but this does not seem to w...

How can I show file sizes with commas when getting a directory listing with 'ls -l'?

You can do 'ls -l' to get a detailed directory listing like this: -rw-rw-rw- 1 alice themonkeys 1159995999 2008-08-20 07:01 foo.log -rw-rw-rw- 1 bob bob 244251992 2008-08-20 05:30 bar.txt But notice how you have to slide your finger along the screen to figure out the order of magnitude of those file sizes. What's a good w...

Find out if pipe's read end is currently blocking

I'm trying to find out if a child process is waiting for user input (without parsing its output). Is it possible, in C on Unix, to determine if a pipe's read end currently has a read() call blocking? ...

Change the ruby process name in top

I would like to change the name of the ruby process that gets displayed in the linux/unix top command. I have tried the $0='miname' approach but it only works with the ps command and in top the process keeps getting displayed as "ruby" Thanks for any hints in advance. ...

How can I pass a password to the "su" command?

I have a program that is going to take a password as input and then do a shell execute to perform a "su" (switch user) command in UNIX. However, I don't know how to pass the password variable to the UNIX su command. The language I have to use for this is pretty limited (UniBasic). Any ideas? ...

How to learn your way through Linux's shell

I want to stop losing precious time when dealing with linux/unix's shell. If I could get to understand it all so well, that would be so great. Otherwise: I may end up loosing a day just for setting up a crontab. I'll keep wondering why the shebang in this script doesn't work. I'll keep wondering what's the real difference between: . ...

To what extent can Version Control help in system administration?

I'm currently tinkering at an OpenBSD system with a view to building myself a firewall and some other bits and bobs. As this is fairly experimental (I'm an OpenBSD n00b, and I've already trashed my system 3 or 4 times), I wonder what experience others have of making part or all of the file system (I'm thinking in particular of /etc) a w...

In Unix, can I run 'make' in a directory without cd'ing to that directory first?

In Unix, can I run 'make' in a directory without cd'ing to that directory first? ...