unix

Double Spacing Complex Sed Output

Let me start off by saying that I know there is probably a much simpler way to do this. But this is what i have and yes hopefully I can make some improvements and/or simplifications at the end. Goal as of this moment To double space the output stored in the $tmp variable below and individually number each line. Doing this should give m...

Logging terminal commands in *nix

Is there a way to log(/var/log) commands executed by users in the *nix terminal? ...

Where are all my inodes being used?

How do I find out which directories are responsible for chewing up all my inodes? Ultimately the root directory will be responsible for the largest number of inodes, so I'm not sure exactly what sort of answer I want.. Basically, I'm running out of available inodes and need to find a unneeded directory to cull. Thanks, and sorry for t...

Creating CVS view from branch with empty directrories

Hi I am using cvs -tag -b "abcdefg" command to tag-branch in my CVS. My cvs repo has an empty directory "obj" in every folder. Whenever I use the command cvs co -r "abcdefg" REPO, I get a complete repo minus the empty folders. I tried using -f option too but it did not work. What is the way to get out of this? Thanks a ton. ...

How to instruct cron to execute a job every second week?

I would like to run a job through cron that will be executed every second Tuesday at given time of day. For every Tuesday is easy: 0 6 * * Tue But how to make it on "every second Tuesday" (or if you prefer - every second week)? I would not like to implement any logic in the script it self, but keep the definition only in cron. ...

In unix/linux how to you find out what group a given user is in via command line?

In unix/linux how to you find out what group a given user is in via command line? ...

sudo nohup nice <-- in what order?

So I have a script that I want to run as root, without hangup and nicely. What order should I put the commands in? sudo nohup nice foo.bash & or nohup nice sudo foo.bash & etc. I suspect it doesn't matter but would like some insight from those who really know. ...

Vim: \n vs. \r

I haven't used vim in a Unix system in a while, but as I recall there was no \r, it was always \n. I'm using gVim under windows and when I search for new line characters I use \n. Searching for \r returns nothing. But when I replace the characters I have to use \r's. \n's give me ^@ Can anyone explain what's going on here? ...

/usr/bin/env questions regarding shebang line pecularities

Questions: What does the kernel do if you stick a shell-script into the shebang line? How does the Kernel know which interpreter to launch? Explanation: I recently wanted to write a wrapper around /usr/bin/env because my CGI Environment does not allow me to set the PATH variable, except globally (which of course sucks!). So I thou...

How to add file extensions based on file type on Linux/Unix?

This is a question regarding Unix shell scripting (any shell), but any other "standard" scripting language solution would also be appreciated: I have a directory full of files where the filenames are hash values like this: fd73d0cf8ee68073dce270cf7e770b97 fec8047a9186fdcc98fdbfc0ea6075ee These files have different original file types...

using regex to find files with certain extensions

What's the regular expression I could use with find -regex to find all files that have a .xls or .csv extension? ...

How can I diff two files with full context?

I have two files with slight differences. A normal diff will show me the differences between the files. With -c or -u I can add an amount of context to each hunk. What options can I pass to diff to see every unchanged line alongside the changes, and get the diff as a single, large hunk? ...

Easiest way to merge partitions under debian (unix)?

I have two unix partitions under debian which I would like to merge (disk space problems :/). What would be the easiest way to do it? I think it would be best to tar or copy files from one partition to the other, delete one and resize the other. I will use parted to resize but how should I copy the files? There are links, permissions and...

How to write a unix filter that outputs only a line every N lines

Suppose to feed the filter standard input with these line: line 1 line 2 line 3 line 4 line 5 line 6 line 7 line 8 line 9 line 10 It would be nicer if someone tell me how to write a script that prints only every 4 lines, in the case of the example input above: line 1 line 5 line 9 ...

Killing a defunct process on UNIX system

I have a defunct process on my system: abc 22093 19508 0 23:29 pts/4 00:00:00 grep ProcA abc 31756 1 0 Dec08 ? 00:00:00 [ProcA_my_collect] <defunct> How can I kill the above process, without a reboot of the machine? I have tried with kill -9 31756 sudo kill -9 31756 ...

Sorting multiple keys with Unix sort

I have potentially large files that need to be sorted by 1-n keys. Some of these keys might be numeric and some of them might not be. This is a fixed-width columnar file so there are no delimiters. Is there a good way to do this with Unix sort? With one key it is as simple as using '-n'. I have read the man page and searched Google ...

Canonical vs. non-canonical terminal input

I am studying for an exam and I am confused as to how canonical vs. non-canonical input/output works in Unix (e.g., curses). I understand that there is a buffer to which "line disciplines" are applied for canonical input. Does this mean that the buffer is bypassed for non-canonical input, or does it simply mean that no line disciplines...

Responsive lightweight remote GUI connection

Currently I know several methods of connecting to a GUI remotely, or running GUI applications remotely: Microsoft Terminal Services (only works for remote windows; installation); VNC (it's slow); XDMCP (requires a remote X server running, has no session persistance); Local X as remote DISPLAY for applications (best solution, but - no s...

Is there a special restriction on commands executed by cron?

I have a crontab that looks like 0 0 * * * pg_dump DB_NAME > /path/to/dumps/`date +%Y%m%d`.dmp which works fine when I run it manually, but not when cron runs it. After digging through the logs, I see Dec 12 00:00:01 localhost crond[17638]: (postgres) CMD (pg_dump DB_NAME > /path/to/dumps/`date +) It looks like a problem with perce...

Piping as interprocess communication

I am interested in writing separate program modules that run as independent threads that I could hook together with pipes. The motivation would be that I could write and test each module completely independently, perhaps even write them in different languages, or run the different modules on different machines. There are a wide variety...