unix

How do you do a case insensitive search using a pattern modifier using less ?

It seems like the only way to do this is to pass the -i parameter in when you initially run less. Does anyone know of some secret hack to make something like this work /something to search for/i ? Edit: Wow how did I miss -i while less is running? Doh! ...

Differences between unix and windows files

Am I correct in assuming that the only difference between "windows files" and "unix files" is the linebreak? We have a system that has been moved from a windows machine to a unix machine and are having troubles with the format. I need to automate the tranlation between unix/windows before the files get delivered to the system in our "...

Getting stack traces on Unix systems, automatically

What methods are there for automatically getting a stack trace on Unix systems? I don't mean just getting a core file or attaching interactively with GDB, but having a SIGSEGV handler that dumps a backtrace to a text file. Bonus points for the following optional features: Extra information gathering at crash time (eg. config files). ...

Why doesn't **find** find anything?

I'm looking for shell scripts files installed on my system, but find doesn't work: $ find /usr -name *.sh But I know there are a ton of scripts out there. For instance: $ ls /usr/local/lib/*.sh /usr/local/lib/tclConfig.sh /usr/local/lib/tkConfig.sh Why doesn't find work? ...

Obscuring network proxy password in plain text files on Linux/UNIX-likes

Typically in a large network a computer needs to operate behind an authenticated proxy - any connections to the outside world require a username/password which is often the password a user uses to log into email, workstation etc. This means having to put the network password in the apt.conf file as well as typically the http_proxy, ftp_...

Is there a Unix utility to prepend timestamps to lines of text?

I ended up writing a quick little script for this in Python, but I was wondering if there was a utility you could feed text into which would prepend each line with some text -- in my specific case, a timestamp. Ideally, the use would be something like: $ cat somefile.txt | prepend-timestamp (Before you answer sed, I tried this: $ ca...

Can you compile Apache HTTP Server and redeploy its binaries to a different location ?

As part of our product release we ship Apache HTTP Server binaries that we have compiled on our (UNIX) development machine. We tell our clients to install the binaries (on their UNIX servers) under the same directory structure that we compiled it under. For some clients this is not appropriate, e.g. where there are restrictions on where...

“rusage” statistics

Hello, I'm trying to use “rusage” statistics in my program to get data similar to that of the time tool. However, I'm pretty sure that I'm doing something wrong. The values seem about right but can be a bit weird at times. I didn't find good resources online. Does somebody know how to do it better? Sorry for the long code. class StopW...

Combining values from different files into one CSV file

I have a couple of files containing a value in each line EDIT: Oops... I figured out the answer to this question while in the midst of writing the post and didn't realize I had posted it by mistake in its incomplete state. I was trying to do: paste -d ',' file1 file2 file 3 file 4 > file5.csv and was getting a weird output. I later ...

Best Method to run a Java Application as a *nix Daemon or Windows Service?

I am looking for the best method to run a Java Application as a *NIX daemon or a Windows Service. I've looked in to the Java Service Wrapper, the Apache Commons project 'jsvc', and the Apache Commons project 'procrun'. So far, the Java Service Wrapper looks like it's the best option... but, I'm wondering if there are any other "Open So...

Delete all but the most recent X files in bash

Is there a simple way, in a pretty standard UNIX environment with bash, to run a command to delete all but the most recent X files from a directory? To give a bit more of a concrete example, imagine some cron job writing out a file (say, a log file or a tar-ed up backup) to a directory every hour. I'd like a way to have another cron job...

Maximum buffer length for sendto?

How do you get the maximum number of bytes that can be passed to a sendto(..) call for a socket opened as a UDP port? ...

Is there any way to prevent find from digging down recursively into subdirectories?

When I do: $ find / It searches the entire system. How do I prevent that? (This question comes from an "answer" to another question.) ...

Unix shell file copy flattening folder structure

On the UNIX bash shell (specifically Mac OS X Leopard) what would be the simplest way to copy every file having a specific extension from a folder hierarchy (including subdirectories) to the same destination folder (without subfolders)? Obviously there is the problem of having duplicates in the source hierarchy. I wouldn't mind if they ...

How do you choose a Linux/Unix/BSD distribution?

I am attempting to choose a Linux, Unix, and/or BSD distribution for development purposes. I want to be able to do things like write shell scripts, develop C, C++, Java, Ruby, Python, etc. apps in a *nix environment, and see things from a different perspective. I'm planning on using a Virtual Machine to do all of this. My first stop was ...

Why doesn't **sort** sort the same on every machine?

Using the same sort command with the same input produces different results on different machines. How do I fix that? ...

Parsing XML using unix terminal

Sometimes I need to quickly extract some arbitrary data from XML files to put into a CSV format. What's your best practices for doing this in the Unix terminal? I would love some code examples, so for instance how can I get the following problem solved? Example XML input: <root> <myel name="Foo" /> <myel name="Bar" /> </root> My desi...

GUI toolkit for rapid development?

I want to write a front-end to an application written in C/C++. I use Solaris 10 and plan to port the application to some other architectures (Windows first). ...

Get current process CPU usage in C

On Windows I can do: HANDLE hProcess = GetCurrentProcess(); FILETIME ftCreation, ftExit, ftKernel, ftUser; GetProcessTimes(hProcess, &ftCreation, &ftExit, &ftKernel, &ftUser); SYSTEMTIME stKernel; FileTimeToSystemTime(&ftKernel, &stKernel); SYSTEMTIME stUser; FileTimeToSystemTime(&ftUser, &stUser); printf("Time in kernel mode = %uh...

Change own process priority in C

On Windows I can do: HANDLE hCurrentProcess = GetCurrentProcess(); SetPriorityClass(hCurrentProcess, ABOVE_NORMAL_PRIORITY_CLASS); How can I do the same thing on *nix? ...