Posted on and Updated on

Substitute a text only in files where it appears

For example, to substitute foo with bar

for f in `grep -lR foo`; do
	echo -n ">> $f";
	sed 's/foo/bar/g' $f > $f.tmp ;
	mv $f.tmp $f ;
	echo " done.";
  • 1) for loops on all files containing the text “foo”, grep -l only show the file name with corresponding text inside.
  • 3) sed replace foo with bar in all file
  • 4) mv save the modification (delete if you don’t want to overwrite the original files, the modified files is named with .tmp at the end)
  • 2) & 5) echo: which file is treated

Posted on and Updated on

Convert multiple files to utf8 using vim

The fastest and more efficient way to batch multiple files encoding conversion :

vim +"argdo se fileencoding=utf-8 | w | bnext" +"q" ` find . -type f -name "*.rsp" `

+”argdo” : execute the following vim commands for each file (filencode, save and next buffer)

+”q” : quit after last one

find : get all files with corresponding name

Posted on and Updated on

ZSH, nohup and background process that lasts…

When I switched to  ZSH, and letting BASH behind, I missed some behaviour : one of them was the ability to quit my terminal while some jobs are still alive.

In ZSH, I get a message like this if I exist with running jobs :

zsh you have running jobs

If I exit again, my jobs are killed. But zsh accept some useful option to overide this :

setopt NO_HUP

First one is for not killing process after terminal exit, and second one is for not warning you about it.

Posted on and Updated on

Install minimum php (no apache)

To code with php, no need to install apache and other dependencies, especially as php has a builtin web server.

apt-get install php5-cli

Then use

php -S localhost:4444

and you’re done.

Posted on and Updated on

Get rid of the Desktop icon in Nautilus 3.10 side bar

Add in ~/.config/gtk-3.0/settings.ini


Remove all entries in ~/.config/user-dirs.dirs but let this one :


If you remove this too, each time nautilus is launched, it will create a ~/Desktop folder.

Remove folder Desktop if it exists

Posted on and Updated on

usb mount and policykit [EN]

When you’re not on the ‘Desktop Environment‘ side and rather be in light linux config, you have to deal with annoying little problems. I’m using DWM as my tiled window manager and loving it for years. It’s fast, flexible and fun. My linux desktop is up and running after a few seconds… (ok, thanks also to the ssd 🙂 ).

But, after I upgraded to Ubuntu 14.04, I’ve lost the ability to mount my usb disks with the file manager (same problem with Nautilus or Thunar). I’m getting this frustrating “not authorized” message.
My work around was to ‘pmount’ the disk. It works but I need to search for the right device before, with dmesg, then provide the right syntax. Not so fun.

After digging a while, I found out that authorizations are managed with policykit. So after reading man page after man page, posts after posts, I found a way to easily mount my usb disks in my file manager.

Just edit a new policykit config file :

sudo nano /etc/polkit-1/localauthority/50-local.d/55-myconf.pkla

The number and the .pkla extension are mandatory to respect. The name ‘myconf’ is as you will.
Inside this file, insert those lines :

[Dealing with disks]

Now, we have to restart DBUS as it’s the service that launch the polkitd daemon

sudo restart dbus

If you launch, as I do, gnome-settings-daemon manually, you need to relaunch it after dbus

gnome-settings-daemon -r &

That’s it ! Plug a usb drive and use your file manager to browse it. No more ‘not authorized’ message !