unix

How to interpret linux's top correctly?

We're running to profile a java program on its memory usage. We have a 512 ram box and top shows that 500 or so MB of ram is used with very little free. However over at the RES column we can see that the jvm is only using 100MB or so. And all the other processes are not even significant (less than 1k). So what exactly is consuming all th...

When does a UNIX directory change its timestamp

I used "touch" on a file, updating the file's timestamp but the parent directory's timestamp did not change. However, (as expected) when I created a new file within the parent directory, the directory's timestamp did change. What criteria do UNIX-like operating systems (specifically AIX) use to determine when to update the timestamp of...

After a new install, the SQLite3 old version persists (OS X)

I've installed the newer version of SQLite3 (3.7.0.1) on my macbook (OS X 10.5) but 'sqlite3 --version' gives me the older version I had on my system: $ sqlite3 --version 3.4.0 I suppose I was expecting this version to be overwritten but that doesn't seem to be the case. Can anyone clue me in? I'd really appreciate it, right now I'm t...

Vim C++ auto complete

How do I enable auto completion in Vim? I tried to do this one, but I'm not proficient with the vimrc file, etc., so it didn't work out. Can you give me step by step instructions on how to do this? Edit I tried installing OmniCppComplete. Followed the instructions, but when I try to use it I get the following error: Error detect...

What is "q.v." in the tcsh man page

Ok, this has been an on-going annoyance, so naturally I thought to bring it here. In the tcsh man page the phrase q.v. is used, and I have no clue why those four characters are inserted. Is it self referential ? a technical reference ? a documentation or language convention ? Here are some examples in context. (+) Variables may be ...

Untar contents to same directory

I have this scenario in UNIX: I am tar'ing files of a directory like this: tar cvf test.tar /dir1/dir2/file1.xml /dir1/dir2/file2.xml When I copy this tar file to a different directory and Untar it, I want the two files(and all the other files) to be untared in the curent directory only. How can I do this? Btw, I must be using the ab...

Make terminal open a file with default editor

Is there a way I can say open file.php in the terminal and have jEdit open the file.php? Now I have to go to a finder window and find the file...which there are too many files and the order of the files keeps changing even though I specify by name. Note: I am working on a remote server. I login via ssh and am using a git repository. I w...

Batch renaming files using UNIX - should I use awk?

I have a large number of image files that i need to rename from the comand line. I believe the best way to do this is to use awk (please correct if this is incorrect). file names are like the following 1038282829128738912-1.jpg Every image file starts with '103' and I want to replace this part of the file name with '201003' - leaving...

Extracting n rows of text from a large csv file

I have a CSV file (foo.csv) with 200,000 rows. I need to break it into four files (foo1.csv, foo2.csv... etc.) with 50,000 rows each. I already tried simple ctrl-v/-c using gui text editors, but the my computer slows to a halt. What unix command(s) could I use to accomplish this task? ...

Regarding Process modifications and address spaces

When we type vi at the prompt in a Unix Shell, we are able to use the Vim Editor. Now the Shell forks another process. AFAIk i read in a book that one Process cannot Modify the other. Then how come in Linux the Shell allows us to open Vim in the terminal itself? I am confused about the fact that if the shell is actually accessing the ...

Copy files that are different?

I have two directories with similar files, (one being a backup), what is a command that allows me to copy over only the files that are different to the backup? cp -rf firstDir/* secondDir is awfully inefficient, since a lot of the files are the same. ...

How to get emacs to highlight and link file paths

Is there some emacs lisp code that would automatically find /nfs file paths in the buffer and highlight/link to them? So clicking on them would open that file? Example path: /nfs/foo/bar/file.txt ...

Why does recursive mode on chmod do everything but recursion?

chmod -R 775 *.cgi only changes permissions on the files in the current directory, the files in the subdirectory don't get modified at all. This is the exact same functionality as simply doing chmod 775 *.cgi. I have seen people use solutions such as with find and whatnot. Ok great, but why does -R mode even exist if it doesn't even acco...

How to go from a multiple line sed command in command line to single line in script

So I have sed running with the following argument fine if I copy and paste this into an open shell: cat test.txt | sed '/[,0-9]\{0,\}[0-9]\{1,\}[acd][0-9]\{1,\}[,0-9]\{0,\}/{N s/[,0-9]\{0,\}[0-9]\{1,\}[acd][0-9]\{1,\}[,0-9]\{0,\}\n\-\-\-//}' The problem is that when I try to move this into a korn shell script, the korn shell throws er...

Read a .Z file (unix compresses file) in Java

Hello, The said file extension is explained here at http://kb.iu.edu/data/abck.html. I want to use a java api to read the contents of a Z file. Neither the ZipFile api or the GZIPInputStream seem to work. I can use the ZipFile api to open normal .zip files. ZipFile zf = new ZipFile("CR93H2.Z"); Enumeration entries = zf.entries(); To...

List environment variables with C in UNIX

Is there a way to enumerate environment variables and retrieve values using C? ...

Shell-Scripting (BASH): What is the best way to toggle a script "on/off" that isn't able to end itself?

Hi, I would like to have a script with an infinite loop, that kills all processes created by this script when it gets executed again. So basically you start the script via terminal: bash poll.sh and it's running infinitely, you open another terminal and again bash poll.sh and all poll.sh processes will get killed. What would be th...

How to easily install and uninstall unix packages

Hey everyone. I'm using the Ubuntu server for some time now. Everything is working fine, installing packages is a piece of cake. Usually I use aptitude or apt-get for package management. But...! There are cases when I need to install a package from a source. No problem usually I do ./configure, make install and so on. But...! There are a...

Appeal of OS X for *nix developers?

This question is for experienced Unix/Linux developers. If you have found that you like Mac OS X better than *nix as a development platform, why is that? I know that hardware configuration is more convenient and graphics are generally more polished, but I'm not referring to those things. I'm asking specifically about functionality rela...

Making python like system calls in java

Is there an equivalent to Python's popen2 in Java? ...