Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts

Tuesday, 27 November 2012

Killing all processes that match a given string

If you want to kill all processes matching a given executable, you can easily use killall:

killall -9 my_executable

But what if you don't want to kill processes based on an executable name, but rather on some argument name, or something else? That is, all processes that match some string?

You can. Here is the trick:

kill -9 $(ps aux | grep -v grep | grep my_process | awk '{print $2}') 

(originally from here)

Friday, 12 October 2012

Using wget to get multiple files from http servers

The Unix wget utility support globbing, but only when pointed to Unix FTP servers. So this could work:

wget ftp://something.com/*.jpg

but this will not

wget http://something.com/*.jpg

What do you do when you want to do this for an http server? A common case is where you have numbers for example, like

http://something.com/0.jpg
http://something.com/1.jpg
http://something.com/2.jpg

etc.

In this case the solution is

wget http://something.com/{0,1,2,3,4,5,6,7,8,9}.jpg

In this case the command will be repeated for all numbers and you get all 10 images in one go.

Thursday, 11 August 2011

Recursive find

Sometimes you don't have locate , or you want just to find recursively below your current directory. Here is a handy alias:

alias fn='find . -name':
Example usage: $ fn "page*.htm"

Tip from Joe Grossberg.

Saturday, 10 May 2008

Create a .tar.gz archive

Ok, this is admittedly really noobish. But it's something I always forget. While the tar -xzvf spell for unpacking archives is well known, only seldomly I need to create archives.

However, here's the magic:

tar -pczf name_of_archive.tar.gz /path/to/directory

That's more a reminder for me...

Saturday, 29 December 2007

Copying whole partitions preserving hidden files and attributes

How do you easily and coherently copy a whole large and complex directory, preserving attribution, hidden files etc? Good old cp -a could not be enough in this case (hidden files would be skipped), and maybe you don't want to use dd (e.g. you could like to move a ReiserFS partition to an ext3 partition). The trick is hidden in the Debian tips , but can be applied to any Linux (and probably Unix) distribution. Since I got crazy yesterday trying to find it again, after using it to move partitions from my old hard drive to a new one, I repost it here:
find . -depth -print0 | cpio --null --sparse -pvd /new/directory
That's it. A 1:1 copy of your filesystem hierarchy is deposited in the new directory. It saved my day.

Thursday, 19 July 2007

Installing the new Oxygen icons under KDE 3

KDE 4 is coming, and it is bringing a truckload of improvements and goodies. Among these, there is the brand-new Oxygen icon theme. Oxygen will be the default icon theme of KDE 4 and it is going to be damn good. Look at the preview to have an idea by yourself.

With a strange move for an open source project, KDE 4 is quite secretive about the new icon theme. The plan is to present the whole suite together, keeping Oxygen as a "novelty", so, even if Oxygen is being currently developed and most icons are already done, there are no official downloads provided for Oxygen. Moreover, the KDE 4 developers somehow "discourage" using Oxygen on a KDE 3 system.

However, Oxygen is open content (Creative Commons Attributions-Share Alike and LGPLv3 dual-licensed) and it is online in the KDE 4 SVN repository. So nothing legally prevents you to download and try the current Oxygen development version on your system.

It is not straightforward to obtain a KDE 3 -installable theme from the KDE 4 SVN repository, however someone (as often happens in the OSS world) has done the dirty work for you. After a bit of googling I found a handy script that automatically downloads the latest revision of Oxygen icons, converts them (using Inkscape for that purpose, so check you have it installed) and packages it as a theme (that is a single .tar.bz2 file) in your home directory.

The script is a bit slow, but works: basically just download the file from the webpage above, unzip it, open a shell, enter in the directory, run ./install.sh as a normal user and wait. When it has finished, just look for the Control Center in your KDE menu and go through Appearance and Themes --> Icons --> Install new theme and open the oxygen-icon-theme.tar.bz2 file in your home directory created by the script. VoilĂ , theme installed.

How does it looks? Really professional and cool. I must admit however that it can look somehow out-of-place on a common KDE 3 system, so probably KDE 4 developers are right -to fully experience Oxygen, better wait KDE 4 at the end of the year. However, here is some screenshot for your pleasure: 1 , 2 , 3 , 4