The Archives

  • 10.Aug.17
    Interlacing file lines shell | fernape | (0)
    Recently I needed to mix several files into one single file. The point was that I needed to interlace the files so I had all the first lines of every file followed by all the second lines and so on. Put it simply, this is what I had: fapesteguia@fapesteguia:~/test$ cat file1 file 1 row 1 file 1 row 2 file 1 row 3 file 1 row 4 file 1 row 5 file 1 row 6 file 1 row 7 file 1 row 8 file 1 row 9 file 1 row 10 fapesteguia@fapesteguia:~/test$ cat file2 file 2 row 1 file 2 row 2 file 2 row 3 file 2 row 4 file 2 row 5 file 2 row 6 file ...
  • 18.Feb.17
    Understanding the strace command shell | fernape | (0)
    strace is a utility that traces system calls and signals. It is very useful for debugging purposes, specially if you don't have the source code of the problematic software. In its simple form it works like this: $ strace ls /tmp strace ls /tmp/ execve("/bin/ls", ["ls", "/tmp/"], [/* 80 vars */]) = 0 brk(0) = 0x1c3e000 access("/etc/", F_OK) = -1 ENOENT (No such file or directory) mmap(NULL, 8192, ...
  • 04.Mar.16
    growisofs has the best command flag ever shell | fernape | (2)
    With all the hype about Star Wars, I think this is very appropriate. growisofs is a DVD command-line recorder. It can be used this way: growisofs -Z /dev/dvd StarWars.avi The command has a lot of options, but one of them will catch your eye in the man page. If you find yourself having problems with growisofs and feel like you can take a risk, try with the -use-the-force-luke= option. For example: -use-the-force-luke=dummy for Test Write mode. Enjoy! and may the Force be with you.
  • 29.Jan.16
    What do you expect? shell | fernape | (0)
    Recently at work, we had to write a script to upload several files to an ftp server. Initially, we developed a first version using here documents. It was not bad, but it wasn't exactly what we needed. We told ourselves: "We just want to do this as if we were typing it". After googling for a couple of minutes, we found expect. expect is an utility to program a dialogue with interactive programs. How does this work? It is something like the following: I would launch this program I would expect something in the terms of this string as a result I would ...
  • 13.Jan.16
    Add timestaps to your bash history shell | fernape | (0)
    bash history is very useful to access your past commands. Sometimes it would be just great to know when a command was typed to be able to correlate it to another event. Imagine we know that there was a change in a repository that might have fixed a heisenbug. But we know that not long ago, we saw the bug again. But are we sure it was before the change in the repository was made? We can solve this (and other problems) by adding time stamps to our bash history. Add the following line to your .bash_profile file: export HISTTIMEFORMAT="%d/%m/%y %T " The ...
  • 02.Dec.14
    Installing YouCompleteMe on FreeBSD shell | fernape | (2)
    Recently, we had a discussion at work about editors and IDEs. And yes, I think Vim is not only a great editor but also a good IDE with the proper plugins installed. There are several nice plugins out there, but I'm going to talk about YouCompleteMe. YouCompleteMe (in short, YCM), is a completion engine for Vim that uses libclang as a backend to support great C/C++ semantic completion. Unlike other pure Vim plugins, YCM needs a component that has to be compiled before you get semantic completion. Although it is not complicated, I'll show you the steps to successfully install YCM ...
  • 09.Jan.14
    Handling rc.conf(5) with sysrc shell | fernape | (0)
    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 boot time:/etc/rc.conf Since it is a very sensitive file, an unfortunate mistake while editing it can break havok if our system does not boot the next time. To avoid these kind of situations, there is a tool called sysrc. sysrc provides a way to edit rc.conf(5) safely ...
  • 14.Aug.13
    Mirroring a site shell | fernape | (0)
    I recently had to mirror a website to make a backup. I found this very useful (though not perfect) wget -mk Hope it helps
  • 09.Aug.13
    PKGng: The new package manager of FreeBSD shell | fernape | (0)
    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 am talking about. The new system is much faster due in part to the use of an SQLite database. Some time ago, the task of re-thinking the package manager was taken over by a group FreeBSD developers. Finally, with the upcoming of the 9.1-RELEASE version, pkg was ...
  • 12.Mar.13
    Spell checking shell | fernape | (0)
    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 leaves us with a prompt in which we can type a word. For instance, if we type: @(#) International Ispell Version 3.1.20 (but really Aspell 0.60.3) hello * The asterisk indicates that aspell found the word in the dictionary. On the contrary, if we type: @(#) International Ispell Version 3.1.20 (but really Aspell 0.60.3) rescoe & ...