EzDevInfo.com

gnu interview questions

Top gnu frequently asked interview questions

Unix mail command: Sort by newest first

When I use the "mail" command, it prints a list of messages in my inbox in a format like this: 1 Super User Mon Jun 9 17:13 86/4716 Complete Registration With Stack Exchange However I've noticed that it does this with the oldest messages first. Is there a way to change this behaviour?


Source: (StackOverflow)

How do you install gnu MAKE without compiler

I'm a little new in this area. I have a virtual machine centos5.1 that doesn't come with make or any compiler... basically stripped down. It doesn't come with any install packages like yum, rpm or apt. In order to install 'make', you have to have a valid compiler like gcc. However, in order to compile GCC, you need to have 'make'. How do I go about installing these dev tools?


Source: (StackOverflow)

Advertisements

sort by word length in Nth column

I've got a column file like this:

1 1 1 AKSDFJADFKASDJFAK
2 1 1 ADKLCJASDLKCJDLACKADCJLKDACJADS
3 1 2 AKLJDFHALKDJFHLKJSDKSDFHAKJFDHAKFHJAKFJ

And I would like to sort the entries by the fourth column, with the longest word first. Any suggestions?


Source: (StackOverflow)

Change specific font in pdf document

I have a PDF file, which has a buggy font (some d's, o's and q's with black color fill inside the circe) which is annoying to read.

How can i change that specific font in the whole document, keeping the file structure?

PS: I am using GNU/Linux, so i prefer a cross-plataform solution.


Source: (StackOverflow)

Difference between find -name with and w/o quotes?

I was going to file a bug to findutils on gnu.org when I saw a notice that asked me whether I knew the difference between these two commands:

find -name *.c    

and

find -name "*.c"

I use find command quite often but I don't think these two have any difference. So I'm curious am I wrong or it's just another GNU guys kidding?


Source: (StackOverflow)

sed Command on BusyBox expects different syntax?

I hope I phrased the question correct. I have a script that makes use of 'sed' a lot. It works great on my ubuntu with the GNU 'sed'. But when I try to run it on BusyBox it fails. Is there a way to get the GNU sed on busybox? I am not a Linux pro.


Source: (StackOverflow)

GNU find with -exec rm removes matches, then complains they don't exist

I have a /domains directory in which I have entries such as

theawesomesite.com
0.2.v.theawesomesite.com
0.3.v.theawesomesite.com

And after testing 0.3, I'll set the main domain to alias the new version. Works really nice. Now, I want to be able to delete all old versions. I tried this:

find /domains -name "*.v.theawesomesite.com" -not -name "0.3.v.*" -ignore_readdir_race -exec rm -fr {} \;

The old domain directories are deleted, but for each of them find complains No such file or directory. I added the -ignore_readdir_race under the idea it would help, but it has not.

Any ideas how to get rid of these complaints and why find is complaining in the first place. It has to be stating after the -exec but I can't figure out why.


Source: (StackOverflow)

linux tar -T - does not work on the fly

I found some problem with linux gnu tar. wheh I use option

-T -  (for file list from stdin) or
-T named_pipe_file    ,

this desn't work on the fly. for example, simple interactive script:

while read x; do echo $x; done|\
tar cvf tar.tar -T -

tar starts archiving only when I press ^D for marking input EOF the same situation is when I use named pipe:

mkfifo named_pipe
tar cvf tar.tar -T named_pipe
while read x; do echo $x; done >named_pipe

It seems tar makes some buffering. But how long is it? I must repack a lot of files to TAR but have little disk space. Then I must do this on the fly. I waht use tar option --remove-files for this. But without interactivity for -T option it's impossobie. In the plan, "while" part of code should unpack file to file sequently and waiting for TAR for removing, and next file. Thanks for ideas :)

my tar version: tar (GNU tar) 1.26 (C) 2011 FSF


Source: (StackOverflow)

Dividing with Gnu's bc

I'm just starting with Gnu's bc and I'm stuck at the very beginning (very discouraging...). I want to divide two numbers and get a float as result:

$bc
bc 1.06.94
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 

15/12
1
15.0/12.0
1
15.000000/12.000000
1
scale(15.00000)
5

The man page says, that division returns a number with the same scale as the initial values. Obviously this is either not true or I'm missing something.

Googling hasn't brought up any new insights (besides that 'BC' can also stand for 'British Columbia').

Do you see my error? Better yet, do you know any good references/tutorials to bc?


Source: (StackOverflow)

How do I add color syntax highlighting to GNU emacs?

I have two versions of emacs available to me on a locked workstation:

$ /usr/local/bin/emacs --version
GNU Emacs 22.3.1

$ /usr/bin/emacs --version
GNU Emacs 21.4.1

In both cases, my terminal type is xterm when I run either version of emacs.

When I run the v21 version of emacs, I get syntax coloring for Perl, HTML, and other modes.

When I run the v22 version, I do not get syntax coloring.

I would like to migrate from the v21 version because the combination of v21 emacs, GNOME Terminal and GNU Screen is eating Ctrl-arrow key chords, which prevents me from moving quickly between words. (OS X Terminal and GNU Screen do not have this issue.) The v22 version allows use of Ctrl-arrow key combinations with GNOME Terminal and GNU Screen.

How do I fix the v22 version (or ask my sys admin to fix) so that it once again highlights syntax and allows me to use Ctrl-arrow key combinations?


Source: (StackOverflow)

How to get the actual directory size (out of du)?

How do I get the actual directory size, using UNIX/Linux standard tools?

Alternative question: How do I get du to show me the actual directory size (not disk usage)?

Since people seem to have different definitions of the term "size": My definition of "directory size" is the sum of all regular files within that directory.

I do NOT care about the size of the directory inode or whatever (blocks * block size) the files take up on the respective file system. A directory with 3 files, 1 byte each, has a directory size of 3 bytes (by my definition).

Calculating the directory size using du seems to be unreliable.
For example, mkdir foo && du -b foo reports "4096 foo", 4096 bytes instead of 0 bytes. With very large directories, the directory size reported by du -hs can be off by 100 GB (!) and more (compressed file system).

So what (tool/option) has to be used to get the actual directory size?


Source: (StackOverflow)

LANG and LANGUAGE environment variable in Debian based systems

It seems both the LANG and LANGUAGE environment variable are used by some programs to determine their user interface language.

What are the exact semantics of these variables and where can I read about their correct usage? The manpage for locale(1) only mentions the LC_* family of environment variables. Additionally there is also an LC_ALL variable commonly in place which isn't described there either.


Source: (StackOverflow)

What should I make my computer do while I'm away from keyboard? [duplicate]

This question already has an answer here:

During the day, usually I'm away from my computer for 3-5 hours. I also sleep 6+ hours every night.

I run Arch Linux x64 on my computer.

Besides the usual things that do not require user intervention (torrenting, backing up data, upgrading the system, etc...), is there anything useful that I can let my computer do while I'm away?

Considering I almost never turn the computer off, it seems like a waste it's sitting there doing nothing. I'm looking for any kind of suggestion, not only machine maintenance.


Source: (StackOverflow)

Can I name GNU screen sessions?

I use multiple sessions for different things. One for work, one for school work and one each project I'm working on. It gets really hard to keep track of the sessions when screen -ls returns

11292.pts-0.chu (09/12/11 14:13:49)     (Detached)
7616.pts-4.chu  (09/01/11 10:31:57)     (Detached)
1834.pts-0.chu  (08/31/11 18:32:16)     (Detached)
1810.pts-0.chu  (08/31/11 18:45:20)     (Detached)

Is there any way I can name my sessions for better control?


Source: (StackOverflow)

find: -exec vs xargs (aka Why does "find | xargs basename" break?)

I was trying to find all files of a certain type spread out in subdirectories, and for my purposes I only needed the filename. I tried stripping out the path component via basename, but it did't work with xargs:

$ find . -name '*.deb' -print | xargs basename 
basename: extra operand `./pool/main/a/aalib/libaa1_1.4p5-37+b1_i386.deb'
Try `basename --help' for more information.

I get the same thing (exactly the same error) with either of these variations:

$ find . -name '*.deb' -print0 | xargs -0 basename 
$ find . -name '*.deb' -print | xargs basename {}

This, on the other hand, works as expected:

$ find . -name '*.deb' -exec basename {} \;
foo
bar
baz

This happens on up-to-date Cygwin and Debian 5.0.3. My diagnosis is that xargs is for some reason passing two input lines to basename, but why? What's going on here?


Source: (StackOverflow)