Skip to content

Why doesn’t “sort file1 > file1” work?

When I am trying to sort a file and save the sorted output in itself, like this the contents of the file1 is getting erased altogether, whereas when i am trying to do the same with ‘tee’ command like this it works fine [ed: “works fine” only for small files with lucky timing, will caus…

vimrc import file

I have a repository of my home config files – http://hg.jackleo.info/home-configs I noticed that my vim configuration is getting bigger and bigger (90% of commits is only related to vim) so I want to trow it to separate repository. The problem is that since i’m using home-config repository at my a…

Why data and stack segments are executable?

I have just noticed that my simple program has its data and stack segments executable. I saw it in /proc/[pid]/maps, and simple code confirmed it. For example: then causes prog to execute int3 instruction. Programs written in C and built with gcc have their data, stack and heap non-executable, so why those wr…

Difference between bash pid and $$

I’m a bash scripting beginner, and I have a “homework” to do. I figured most of the stuff out but there is a part which says that I have to echo the pid of the parent bash and the pid of the two subshells that I will be running. So I looked online and found this (The Linux documentation proj…

pass stdout as file name for command line util?

I’m working with a command line utility that requires passing the name of a file to write output to, e.g. The only thing it writes to stdout is a message that indicates that it ran successfully. I’d like to be able to pipe everything that is written to output.txt to another command line utility. M…

Print contents of a PDF to the command line

I’m looking for a command-line program that will print out the text of a PDF file, just like cat for a text file. I’ve found pdftotxt, and that would be workable, but I’d prefer something that replicates the cat functionality because I want to pipe to grep. Thanks! Answer On the man pages fo…

Determine Device of Filesystem in Python

How do you use Python to determine which Linux device/partition contains a given filesystem? e.g. Answer It is not the purdiest, but this will get you started: On OS X: On Ubuntu: To get the device name, chop off the minor number from the partition name. On OS X, also chop the ‘s’ + minor number.