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.Mar.09
    Play Tetris at the command line fun | rafacas | (0)
    I have been suscribed to sed-users group for quite a while. At sed's home page there is a section named gamez, where one can see some games written in sed such as tic tac toe, pong, sokoban, arkanoid. Some members have contributed more games, like a Julia who wrote tetris, sedtris. Are they not real commandliners? ;-) The following image is a screenshot. Do you feel like gaming?
  • 04.Mar.09
    Removing blank lines from a file shell | rafacas | (0)
    Sometimes I need to remove blank lines from a specific file. I usually do it with the two following commands: $ grep -v "^$" file or $ sed '/^$/d' file Obviously, if you want to save the output you should redirect it to another file, for example: $ sed '/^$/d' file1 > file2
  • 02.Feb.09
    Currency conversion script scripts | rafacas | (1)
    In this time of crisis perhaps we need to pay more attention to financial issues. I am interested in converting some currencies so I have written a script that given two currencies, converts on to the other. The script searches the info on Google Finance's page. An example of its usage is: $ ./ EUR USD 1 EUR = 1.316 USD The available currencies are: EUR - Euros USD - United State Dollar GBP - British Pound JPY - Japanese Yen CHF - Swiss Franc CAD - Canadian Dollar AUD - Australian Dollar INR - Indian ...