unix

Hidden (or not commonly known) windows and unix commands?

What is that one not usually known command in unix and windows that you know? It is heard that windows contains several hidden applications which sometimes may be very useful. ...

Shell script - search and replace text in multiple files using a list of strings

[edited] I have a file "changesDictionary.txt" containing (a variable number of) pairs of key-value strings. e.g. "textToSearchFor" = "theReplacementText" (The format of the dictionary is unimportant, and be changed as required.) I need to iterate through the contents of a given directory, including sub-directories. For each file en...

How to isolate causes of system hang on Unix/OSX

I am on OSX, and my system is becoming unresponsive for a few seconds roughly every 10 minutes. (It gives me the spinning beach ball of death). I was wondering if there was any way I could isolate the problem (I have plenty of RAM, and there are no pageouts/thrashing). Any Unix/OSX tools that could help me monitor and isolate the cause o...

How do I write file modification dates programmatically in POSIX?

Hello. I would like to touch my files from C code to modify their access date. This does not seem to work: struct stat fileSt; lstat(path, &fileSt); fileSt.st_mtime = time(NULL); Thank you for help. ...

What choices do I have on MS Windows platforms for the equivalent of SUID from Unix-based platforms?

To understand what I'm asking, it's important to distinguish from among the several uses of SUID in Unix. I have a project that uses an executable in the user's PATH which is owned by the project and which has the SUID bit set. In this way, when it runs, it runs in the context of the file's owner, not the calling user. This way, it has ...

How do you detach the 2nd screen from within another screen?

I've accidentally attached to a 2nd GNU screen session from within an existing screen session and cannot detach or issue commands to the inner screen. I remember figuring out how to do that before but completely forgot and would like to keep it as reference. One way is to detach the inner screen by doing screen -dr from shell, but what ...

unix-fork-monitor-child-progress

I have an application where a bit of parallel processing would be of benefit. For the purposes of the discussion, let's say there is a directory with 10 text files in it, and I want to start a program, that forks off 10 processes, each taking one of the files, and uppercasing the contents of the file. I acknowledge that the parent progr...

What's the deal with the banner command?

In some versions of UNIX there's a banner command (usually /usr/bin/banner) that prints great output like this: ##### ####### # ##### # # # # # # # # # # # # # # # # # # ##### # # # # ### # # ####### # # # # # # # # # # # # ...

Howto Free Inode Usage

Hi, I have a disk drive where the inode usage is 100% (using df -i command). However after deleting files substantially, the usage remain 100%. What's the correct way to do it then? How is it possible that a disk drive with less disk space usage can have higher Inode usage than disk drive with higher disk space usage? ...

Why doesn't my 'find' work like I expect using -exec?

I'm trying to remove all the .svn directories from a working directory. I thought I would just use find and rm like this: find . -iname .svn -exec 'rm -rf {}' \; But the result is: find: rm -rf ./src/.svn: No such file or directory Obviously the file exists, or find wouldn't find it... What am I missing? ...

I want to make a conditional cronjob

I have a cron job that runs every hour. It accesses an xml feed. If the xml feed is unvailable (which seems to happen once a day or so) it creates a "failure" file. This "failure" file has some metadata in it and is erased at the next hour when the script runs again and the XML feed works again. What I want is to make a 2nd cron job ...

How can I monitor traffic going through a pipe?

The situation I have is this: I'm redirecting input from one spot in my program to another through a pipe. However, it does not appear that this is working correctly, so I'd like to monitor what's going through the pipe. Currently, I'm using dup2() to simply overwrite the stdin and stdout from the pipe. How can I monitor what's going b...

How can I follow and fully report on a chain of symlinks?

What are the best tools/programming-techniques for following a complicated nesting of symlinks and completely capturing and reporting on every symlink along the way, including those in the middle of a path (See below for more info). Here's a specific example. Consider the following output from a shell command ls -l /Library/Java/Home...

gunzip preform task and rezip

Hello all I want to perform this awk -F, '$1 ~ /F$/' file.dat on a whole direcory of gziped files I want to be able to loop through each file unzip it perform the above command (print out any findings) rezip and move onto the next zipped file how can this be done? Thanks ...

How to find path from where current process/executable is running?

I am running some executables while connected to a local unix server box. Say, I'm trying to run an executable 'abc'. Now the server might have provided an alias for 'abc'.. How do I get to know of this path? As in, if I invoke 'abc', it might actually run it from, say, /opt/corp/xyz/abc .. How do I get to know from what path I'm invoki...

socket behaviour when in blocking mode

I'm interested in the behavior of send function when using a blocking socket. The manual specifies nothing about this case explicitly. From my tests (and documentation) it results that when using send on a blocking socket I have 2 cases: all the data is sent an error is returned and nothing is sent In lines of code (in C for exampl...

UNIX symbol referencing error

Greetings Everyone. I'm currently trying to compile a multiple-language program (C, C++ and FORTRAN) using GNU compilers in UNIX (g++, gcc & f77 respectively). All my sources are compiling into objects with no errors however I encounter a symbol referencing error as they are linked as shown below: f77 -L/usr/sfw/lib -R/usr/sfw/lib -lg...

Where can I get a printed copy of the Open Group Base Specifications?

I find myself using the Open Group's base specifications quite a bit when I work. Using them online is fine, but I'd like to have a printed version. I found the site here, but the site says a printed version is unavailable. The html version is freely available, but the PDF requires paying a 4 figure membership fee, which I'm not able to...

program runs when launched by make, but not via shell - crazy nonsense!

I wrote a C program in which I did some pretty heavy stack allocation, around 2 MiB. Since I use the poor man's IDE* I was automatically running the program via make in order to test it, each time I compiled. I had pretty much wrapped everything up, but for some reason, during some of the final optimization, I ran it directly from the s...

How do you resolve issues with named pipes?

I have a binary program* which takes the contents of a supplied file, processes it, and prints the result on the screen through stdout. For an automation script, I would like to use a named pipe to send data to this program and process the output myself. After trying to get the script to work I realized that there is an issue with the bi...