Report inadequate content

Bash, Linux in Harecoded

23/11/2013

Kill processes using string search

A lot of Linux distributions (and Mac) come with a handy command named pkill installed by default. This command is very useful to kill processes in a more natural way.

Instead of doing a kill/killall based on the ID of the process or the binary name, you can just pass a string that appears in any part of the process list, including the parameters you used to start a...

7/06/2013

Converting a CSV to SQL using 1 line in bash

The command line is very powerful and can do amazing stuff in one single line by pipelining a series of commands. This post is inspired after creating a line that mixed sed and awk, but with just only awk I'll show you an example on how to convert a CSV file to an SQL insert

Let's take an input CSV named events-2013-06-06.csv with 16 columns per line. It looks like...

14/02/2012

Contar veces que se pide una URL (y las que no es esa URL)

Hay veces que queremos saber cuántas veces se ha pedido una URL en nuestro servidor y Google Analytics o otro servicio de monitorización basado en Javascript no está disponible. Entonces siempre podemos recurrir a la fuente original de datos, los logs de acceso (esos gran incomprendidos y frecuentemente abandonados) de Apache, Nginx o donde sea.

Si por ejemplo queremos...

14/09/2005

Script for compressing files with gzip within the terminal with date

This is a simple bash script to compress in tar.gz (gzip) format a file or folder appending date to file name.

Save this file as gzip.sh and give it execution permissions. From terminal i could be: chmod 755 gzip.sh This script does the following:

Checks if you passed exactly 2 arguments Compresses your source Adds the date on the resulting filename Optionally changes permissions of...