Linux, programming, computers and life

April 26, 2007

annoying people

Filed under: life

People which do not press Ctrl-C or Ctrl-Insert for copy and Ctrl-V or Shift-Insert for paste and instead use right-click or “Edit” menu…
I find it really really annoying!

Technorati Tags: , ,

April 25, 2007

suspending stuff in linux command line

Filed under: CLI, linux

I suspect most linux (and other unixes such as *bsd, solaris and so on) users know how to suspend a currently running job in the terminal. You just have to press “Ctrl-Z”. For example:
>ls
012linux.tar.gz
[1]+  Stopped&nbspls –color

- I pressed Ctrl-Z really fast here :) . Suspended job number is “1″.

There are some operations you can do with the suspended process. fg command will bring it back to the foreground. bg will put it in the background (the same as appending & to the command). kill %% will kill last job. jobs will display all the jobs in the current terminal, and with job number from that list you can do bg %job-number, fg %job-number and kill %job-number.

But all this is more or less common knowledge. Now to the interesting stuff. Did you know you can suspend telnet, rsh, rlogin and ssh sessions too? Well, you can! In order to do so press tilde (yes, ‘~’) - note it’ll not be displayed and now press “Ctrl-Z” - the session will be suspended. Use fg command to get back to it when needed. Here’s an example with ssh session:
a: /> ssh d
Last login: Fri Apr 6 12:34:42 2007 from xxx.xxx.xxx.xxx
d: /> hostname
d
d: /> ~^Z [suspend ssh]

Suspended
a: /> hostname
a
a: /> jobs
[1] + Suspended ssh d
a: /> fg %1
ssh d
hostname
d
d: />

I hope you’ll find it useful.

Technorati Tags: , , , , , , ,

April 16, 2007

redundant includes in c/c++

Filed under: programming, c++

From time to time, when i remove redundant #include statements from our project, i wonder - is there an automatic tool to do this?
As a first step it’d be nice to have a tool which removes really redundant #includes - those which will not interfere with project build. As a second step - it’d be really nice to have suggestions to use forward declarations where possible instead of #includes.
For a small project the problem can be solved manually, but for a large one, with several build targets… well - automation is a must.

Any suggestions on such a tool?

Technorati Tags: , ,

April 7, 2007

awk/sort/grep/sed and friends vs Ms Excel and OO Calc

Filed under: CLI, GUI, linux, awk

Recently i had a long text file (about 114K lines) which contained strictly formatted lines (output from some of our tools) which i wanted to sort by a certain columns.
While my first solution is usually command line based i thought “I will need a lot of different sorts - let’s do it in Excel - it’ll probably be faster over all”. So i went to my remote desktop, opened Excel and imported the file - which was very easy (i believe there’s File->Import and even File->Open worked). However there’s a limit of 64K lines in Excel - so i got less then 50% of the file. I didn’t give up. I remembered i have OO installed so i launched Calc and, after some time spent in menus browsing (well, there’s File->Export but no File->Import, i believe the solution was somewhere in Insert menu), i imported the file. Well. A surprise - OO also has line amount limitation.
I’m human after all, and i gave up. In order to find minimal and maximal values in 2nd column of the file i needed to do the following:

sort -un -k 2 MyFile | head -n 2
and
sort -unr -k 2 MyFile | head -n 2

Windows users will not even think of this solution…. And with sort, grep, awk and sed one can truly make wonders. Go read the man pages!

Technorati Tags: , , , , , , ,

Get free blog up and running in minutes with Blogsome
Theme designed by Gary Rogers