unix

How does the AND-operator work in the FIND-command?

My last question expanded, so let's analyse things separately. AND-operater, Intersection? I will give an example: $ find . | awk -F"/" '{ print $2 }' .zcompdump .zshrc .zshrc_copy .zshrc_somequy .bashrc .emacs $ find ~/bin/FilesDvorak/.* -maxdepth 0 | awk -F"/" '{ print $6 }' .bashrc .emacs .gdbinit .git .profile When I save the...

What interesting things can be done with dcop?

I have been using UNIX for years and the dcop command only recently came to my attention. What is its primary purpose and is using it in any process a sign of poor design? ...

find -exec cmd {} + vs | xargs

Which one is more efficient over a very large set of files and should be used? find . -exec cmd {} + or find . | xargs cmd (Assume that there are no funny characters in the filenames) ...

Is it reasonable to try and modify the Linux kernel ?

So i want to try a new concept that involves deep modifications of the Linux kernel, and i wanted to know if is it worth to try or if it is too complicated ? ...

Distinguishing a pipe from a file in Unix

Given a FILE*, is it possible to determine the underlying type? That is, is there a function that will tell me if the FILE* is a pipe or a socket or a regular on-disk file? ...

split video stream MPEGTS(H264) into file chunks under unix

Q: How to split MPEGTS(H264) video stream into file chunks? Searching the way of splitting MPEGTS video stream encoded to H264 into accurate file chunks. The challenge is that the stream need to be saved 24/7 and no data should be lost. Thinking about split(1), but there is a problem with video frames. If video frame will be cut in the...

Unable to stop the creation of backups to root by Vim/Emacs

Problem 1: my Vim makes backups with the extension ~ to my root I have the following line in my .vimrc set backup backupdir=~/tmp/vim//,~/tmp//,.//,/var/tmp//,/tmp//$ However, I cannot see a root directory in the line. Why does my Vim make backups of my shell scripts with the extension ~ to my root? Problem 2: my Zsh run my shel...

How to attach a file using mail command on Linux?

I'm on a server running a Linux shell. I need to mail a simple file to a recipient. How to do this, prefereably using only the mail command? UPDATE: got a good solution, using mutt instead: $ echo | mutt -a syslogs.tar.gz [email protected] ...

Unable to source .profile without .zshrc

I have the following lines in my .zshrc source /etc/profile source $HOME/.profile My .profile is not loaded without them, although .profile should be loaded by default in Unix systems. How can you load .profile without sourcing it at .zshrc? ...

Which files shoud only be at Root?

My Mac saves my Vim's temporary files, my Scanner's log files and mach_kernel -files to my Root. I did not set this procedure up. I am at the moment removing files at my root, since many of them seem to be just swap files. I have the idea that only folders and system's symlinks should be at root. Which files should only be at Root? ...

How to guarantee read() actually sends 100% of data sent by write() through named pipes

I've got the following two programs, one acting as a reader and the other as a writer. The writer seems to only send about 3/4 of the data correctly to be read by the reader. Is there any way to guarantee that all the data is being sent? I think I've got it set up so that it reads and writes reliably, but it still seems to miss 1/4 of th...

How to redirect TO stdout?

I have a UNIX application written in ansi C that writes data directly to a file. This file is specified by one of the argument parameters. For testing purposes, I can use /dev/null for the filename, which effectively redirects the output to nothing. I would like to be able to redirect the output to stdout by a similar method. Is th...

Portable way to pass file descriptor between different processes

On most UNIX systems passing an open file between processes can be easily done for child/parent processes by fork(); however I need to share a fd "after" the child was already forked. I've found some webpages telling me that sendmsg() may work for arbitary processes; but that seems very OS dependent and complex. The portlisten seems lik...

Detecting the output stream type of a shell script

I'm writing a shell script that uses ANSI color characters on the command line. Example: example.sh #!/bin/tcsh printf "\033[31m Success Color is awesome!\033[0m" My problem is when doing: $ ./example.sh > out or $./example.sh | grep The ASCII codes will be sent out raw along with the text, mucking up the output and just gener...

how to evaluate a given path within a bash shell

Hi all, Is there a bash command that takes as input a file path and returns an absolute file path? More specifically I would like a command that takes as input a path such as: /tmp/yaneeve/kit/linux/../../output/kit/SOURCES//usr//apps/myapp/lib and returns the path: /tmp/yaneeve/output/kit/SOURCES/usr/apps/myapp/lib Thanks! ...

How can I count unique terms in a plaintext file case-insensitively?

This can be in any high-level language that is likely to be available on a typical unix-like system (Python, Perl, awk, standard unix utils {sort, uniq}, etc). Hopefully it's fast enough to report the total number of unique terms for a 2MB text file. I only need this for quick sanity-checking, so it doesn't need to be well-engineered. ...

In c, how to make a file descriptor blocking?

Given an arbitrary file descriptor, can I make it blocking if it is non-blocking? If so, how? ...

Merge multiple .so shared libraries

Say I have a.so and b.so. Can I produce c.so as a single shared library with all the functions exported by a and b, of course resolving all intra-dependencies (i.e. all functions of b.so called by a.so and the other way around)? I tried gcc -shared -Wl,soname,c.so -o c.so a.so b.so but it doesn't work. Same goes if I archive a.o and ...

Set up svnperms pre-commit hook

I'm trying to implement svnperms into a repository, but am having difficulty with a few things: pre-commit has the execute permissions: -rwxrwxr-x 1 svnadm svn 3018 May 27 10:11 pre-commit This is my call to svnperms within pre-commit: # Check that the author of this commit has the rights to perform # the commit on t...

Unable to diff files in two separate branches in Git

I have FileA in branchA and FileB in branchB. The problem is that I can access only one file at time. I would like to be able to compare the files by FileMerge or meld, since they are the only diffTools whichI have found for Mac. How can you diff by meld/FileMerge the two files? [Solved]: 1st developed Problem: FileMerge does not al...