unix

Are there any good recent reference books on IPC programming?

I grew up on UNIX Network Programming, Volume 2, Second Edition: Interprocess Communications (RIP, Richard Stevens), which was the essential reading for designing a multiprocess program back in the days. Re-reading it, it is rather lacking in more modern multiprocess/multithread topics, such as dbus, etc. Are there any good books which ...

Are there any resources for becoming a Cygwin "power user"?

I've got it configured, but I want more from it...maybe Cygwin isn't the right tool, but I like how it provides a *nix-like environment within Windows. ...

Converting scripts from ksh to bash.

I have some ksh scripts which I'd like to convert to run with bash instead. Are there any useful on-line resources for this? I'm really looking for a list of differences between the two shells and any gotchas I might encounter, although all information is welcome :-) ...

How can I send the stdout of one process to multiple processes using (preferably unnamed) pipes in Unix (or Windows)?

I'd like to redirect the stdout of process proc1 to two processes proc2 and proc3: proc2 -> stdout / proc1 \ proc3 -> stdout I tried proc1 | (proc2 & proc3) but it doesn't seem to work, i.e. echo 123 | (tr 1 a & tr 1 b) writes b23 to stdout instead of a23 b23 ...

How do I use my pager (more/less) on error output only

I have a program that spits out both standard error and standard out, and I want to run my pager less on the standard error, but ignore standard out. How do I do that? Update: That's it ... I didn't want to lose stdout ... just keep it out of pager program 2>&1 >log | less then later less log ...

What does the number in brackets shown after unix command names mean ?

E.g man(1), find(3), updatedb(2) ? what do these numbers mean ? ...

Equivalent of *Nix 'which' command in Powershell?

Does anyone know how to ask powershell where something is? For instance "which notepad" and it returns the directory where the notepad.exe is run from according to the current paths. ...

How do I get the unix find command to print out the file size with the file name?

If I issue the find command as follows: $find . -name *.ear It prints out: ./dir1/dir2/earFile1.ear ./dir1/dir2/earFile2.ear ./dir1/dir3/earFile1.ear What I want to 'print' to the command line is the name and the size: ./dir1/dir2/earFile1.ear 5000 KB ./dir1/dir2/earFile2.ear 5400 KB ./dir1/dir3/earFile1.ear 5400 KB ...

C++: how to get fprintf results as a std::string w/o sprintf

I am working with an open-source UNIX tool that is implemented in C++, and I need to change some code to get it to do what I want. I would like to make the smallest possible change in hopes of getting my patch accepted upstream. Solutions that are implementable in standard C++ and do not create more external dependencies are preferred. ...

How can I check for a file size and add that result in an Excel spreadsheet in Perl?

Currently I monitoring a particular file with a simple shell one-liner: filesize=$(ls -lah somefile | awk '{print $5}') I'm aware that Perl has some nice modules to deal with Excel files so the idea is to, let's say, run that check daily, perhaps with cron, and write the result on a spreadsheet for further statistical use. ...

Can Unix shell script be used to manipulate databases?

I have to read data from some files and insert the data into different tables in a database. Is Unix shell script powerful enough to do the job? Is it easy to do the job in shell script or should I go about doing this in Java? ...

Determine the size of a pipe without calling read()

I need a function called SizeOfPipe() which should return the size of a pipe- I only want to know how much data is in the pipe and not actually read data off the pipe itself. I thought the following code would work fseek (pPipe, 0 , SEEK_END); *pBytes = ftell (pPipe); rewind (pPipe); but fseek dosent work on file descriptors. Anothe...

Managing authorized_keys on a large number of hosts.

What is the easiest way to manage the authorized_keys file for openssh across a large number of hosts? If I need to add or revoke a new key to an account on 10 hosts say, I must login and add the public key manually, or through a clumsy shell script, which is time consuming. Ideally there would be a central database linking keys to acc...

Bash or Ksh ?

I'm not new to *nix, however lately I have been spending a lot of time at the prompt to do my development for my job. My question is what are the advantages of using Korn Shell or Bash Shell? Where are the pitfalls of using one over the other? Looking to understand from the perspective of a user, rather than purely scripting. ...

Detecting a chroot jail from within

How can one detect being in a chroot jail without root privileges? Assume a standard BSD or Linux system. The best I came up with was to look at the inode value for "/" and to consider whether it is reasonably low, but I would like a more accurate method for detection. [edit 20080916 142430 EST] Simply looking around the filesystem is...

What is a good equivalent to Perl lists in bash?

In perl one would simply do the following to store and iterate over a list of names my @fruit = (apple, orange, kiwi); foreach (@fruit) { print $_; } What would the equivalent be in bash? ...

How to autocomplete at the Korn shell command line with the vi editor

In the Korn shell on AIX UNIX Version 5.3 with the editor mode set to vi using: set -o vi What are the key-strokes at the shell command line to autocomplete a file or directory name ? ...

How to suppress Terminated message after killing in bash?

How can you suppress the 'Terminated' message that comes up after you kill a process in a bash script? I tried set +bm, but that doesn't work. I know another solution involves calling 'exec 2> /dev/null', but is that reliable? How do I reset it back so that I can continue to see stderr? Thanks ...

How can I set triggers for sendmail?

If my email id receives an email from a particular sender, can I ask sendmail to trigger a different program and pass on the newly arrived email to it for further processing? This is similar to filters in gmail. Wait for some email to arrive, see if it matches the criteria and take some action if it does. ...

How can I extract a range of lines from a text file on unix?

I have a ~23000 line sql dump containing several databases worth of data. I need to extract a certain section of this file (i.e. the data for a single database) and place it in a new file. I know both the start and end line numbers of the data that I want. Does anyone know a unix command (or series of commands) to extract all lines from...