unix

Common Causes of Operating System Crashes

I am interested to learn: what are the most common technical causes (from the perspective of operating system programming) of an operating system crash (not limited to Windows crashes)? I'm looking for an answer not like "too many apps open", but what specifically happens when too many apps are open that causes the crash. ...

count (non-blank) lines-of-code in bash

In Bash, how do I count the number of non-blank lines of code in a project? ...

Open an Emacs buffer when a command tries to open an editor in shell-mode

I like to use Emacs' shell mode, but it has a few deficiencies. One of those is that it's not smart enough to open a new buffer when a shell command tries to invoke an editor. For example with the environment variable VISUAL set to vim I get the following from svn propedit: $ svn propedit svn:externals . "svn-prop.tmp" 2L, 149C[1;1H ~...

What is the best way to forward a single qmail alias to /dev/null?

I would like to trash the mail received by a single qmail alias. I don't want any mail delivery errors, and I want qmail to be happy about having delivered the mail. How can I do this, preferably without adding another local email account? ...

Why do my keystrokes turn into crazy characters after I dump a bunch of binary data into my terminal?

If I do something like: $ cat /bin/ls into my terminal, I understand why I see a bunch of binary data, representing the ls executable. But afterwards, when I get my prompt back, my own keystrokes look crazy. I type "a" and I get a weird diagonal line. I type "b" and I get a degree symbol. Why does this happen? ...

Unix Script reading a specific line and position

I need to have a script read the files coming in and check information for verification. On the first line of the files to be read is a date but in numeric form. eg: 20080923 But before the date is other information, I need to read it from position 27. Meaning line 1 position 27, I need to get that number and see if it’s greater then ...

xsd to rnc (or rng) conversion (unix command line)

A brief search shows that all available (unix command line) tools that convert from xsd (XML Schema) to rng (RelaxNG) or rnc (compact RelaxNG) have problems of some sort. First, if I use rngconv: $ wget https://msv.dev.java.net/files/documents/61/31333/rngconv.20060319.zip $ unzip rngconv.20060319.zip $ cd rngconv-20060319/ $ java -jar...

Quickly check whether sudo permissions are available

I want to be able to quickly check whether I both have sudo access and my password is already authenticated. I'm not worried about having sudo access specifically for the operation I'm about to perform, but that would be a nice bonus. Specifically what I'm trying to use this for is a script that I want to be runnable by a range of users...

Command-line Unix ASCII-based charting / plotting tool

Is there a good command-line UNIX charting / graphing / plotting tool out there? I'm looking for something that will plot xy points on an ASCII graph. Just to clarify, I'm looking for something that will output a graph in ASCII (like ascii-art style), so I can use it over an interactive shell session without needing X. ...

What processes are using which ports on unix?

Hi there, I need to find out what ports are attached to which processes on a unix machine (HP Itanium). Unfortunately, the lsof is not installed and I have no way of installing it. Does anyone know an alternative method? A fairly lengthy google hasn't turned up anything. Thanks. ...

How do you pre allocate memory to a process in solaris?

My problem is: I have a perl script which uses lot of memory (expected behaviour because of caching). But, I noticed that the more I do caching, slower it gets and the process spends most of the time in sleep mode. I thought pre-allocating memory to the process might speed up the performance. Does someone have any ideas here? Update:...

How do you get what a symbolic link points to without grep?

Say you have a symbolic link, i.e., a -> b. In *nix, is there a command that will simply output what 'a' points to (i.e., 'b') but with nothing else? Typically we do a ls -l and pipe it to grep or something, but say I don't want to do any parsing. Is there a way to do this? ...

How do I list all cron jobs for all users?

Is there a command or an existing script that will let me view all of a *NIX system's scheduled cron jobs at once? I'd like it to include all of the user crontabs, as well as /etc/crontab, and whatever's in /etc/cron.d. It would also be nice to see the specific commands run by run-parts in /etc/crontab. Ideally, I'd like the output in a...

Colored grep?

Sometimes coloring a logfile or other gives a good overview when looking for stuff and behaviors I just saw that grep have a coloring feature grep -C 99999 --color <regexp> <filename> What other methods are there? ...

Connecting input _and_output between of two commands in shell/bash

I have two (UNIX) programs A and B that read and write from stdin/stdout. My first problem is how to connect the stdout of A to stdin of B and the stdout of B to the stdin of A. I.e., something like A | B but a bidirectional pipe. I suspect I could solve this by using exec to redirect but I could not get it to work. The programs are int...

Checking Unix script ftp return codes.

I am currently creating an overnight job that calls a Unix script which in turn creates and ftps a file. I would like to check all possible return codes. The unix man for ftp doesn't list return codes. Does anyone know where to find a list? Anyone with experience with this? We have other scripts that grep for certain return strings ...

How do I use a shell command to tar a list of files and folders with exclusions

Hi, How do I tar a list of files and folders (all in the same directory) with the exclusion of a single directory (which contains a huge amount of data) ...

How can I use xargs to copy files that have spaces and quotes in their names?

I'm trying to copy a bunch of files below a directory and a number of the files have spaces and single-quotes in their names. When I try to string together find and grep with xargs, I get the following error: find .|grep "FooBar"|xargs -I{} cp "{}" ~/foo/bar xargs: unterminated quote Any suggestions for a more robust usage of xargs? ...

unix path searching C function

Hi, I am programming a UNIX shell and I have to use the execv() system call to create a process. One of the parameters for execv() is the filepath for the executable. So if somebody types in /bin/ls, it will run the ls executable. But what I need is a function that when ls is typed, it will search for the filepath of ls (like the "whi...

Slicehost installation profile

I'm no UNIX Guru, but I've had to set up a handful of slices for various web projects. I've used the articles on there to set up users, a basic firewall, nginx or apache, and other bits and pieces of a basic web server. I foresee more slice administration in my future. Is there a more efficient way to set up users, permissions, and sof...