Categoría : shell

Handling rc.conf(5) with sysrc

FreeBSD uses the traditional BSD boot system as opposed to the system used in Linux, i.e SysV. This means that in FreeBSD, we have a directory called /etc/rc.d with a bunch of scripts that bring our system up and running. Alongside these scripts, there is a file used to control some configuration variables used at […]

Leer Más →

PKGng: The new package manager of FreeBSD

So what’s PKGng? pkg is the new package manager of FreeBSD. Packages in FreeBSD used to be managed using several different commands, some of them with overlapping functionality (pkg_delete, pkg_deinstall). The whole system was functional but inefficient. It was also slow due to the underlying infrastructure. Everyone who has ever used pkg_info knows what I […]

Leer Más →

Limit running time to a program

There is no obvious way to specify that a program should run for no longer than x seconds. The following stackoverflow question solves it in a very perlish-way. Define a helper function doalarm: $ doalarm () { perl -e ‘alarm shift; exec @ARGV’ “$@”; } # define a helper function And you are done. $ […]

Leer Más →

Spell checking

aspell is a command-line spell checker. It is a replacement for the older ispell. It can be used to manage dictionaries, to check a complete file, or words typed in your terminal, among other uses. We can invoke aspell this way: $ aspell -a –lang=en @(#) International Ispell Version 3.1.20 (but really Aspell 0.60.3) This […]

Leer Más →

Use of find with regular expressions

I found myself needing to write a clean: rule in a makefile which would wipe out all the auxiliary files generated by latex (among other things). Moreover, the project has some subdirectories in which there might be more of those files. Apart from finding files by date, size, modification time… the find utility can use […]

Leer Más →

When you think everything is lost…

I have seen people many times doing something like this: $cat binary_file The problem with the above is that usually you end up with a prompt that looks like this: �g`�g���i`�i��k`�kX@l`(l � Whatever you type, you get garbage in your terminal. In this case, what most people do is to despair and close the terminal, […]

Leer Más →

Make colored output

I found a nice script in stackoverflow about how to color the output of make in bash. It works by filtering the output and looking for certain expressions to highlight. Placing this function definition in your .bashrc file defines a bash make function which gets executed instead of the command. This way we can shadow […]

Leer Más →

gdb & nice Vim macro

Imagine we have a simple program like the one below: #include <stdio.h> int main(int argc, char **argv) { char *str = “Hello guys, this is just a bit large string to test a nice Vim macro”; printf(“%sn”, str); return (0); } This program is pretty simple, but it will serve its purpose. Imagine we have […]

Leer Más →

1 2