Showing posts with label sed. Show all posts
Showing posts with label sed. Show all posts

Sunday, May 22, 2011

Tetris in Command Line

Ha ha! That's really funny. I never think about even sed can be used to write games such as Tetris!

I just wondered how to play Tetris in command line. Googled it and found several results with source code. There are three of them I've played:
  1. Tetris for the command line with Python Curses (in Python)
  2. Play Tetris at the command line (in sed)
  3. tt: Tetris for Terminals (in C)
To compile tt, you may need to install ncurses, or you will get the following errors:
utils.c:32:20: error: curses.h: No such file or directory
utils.c:33:18: error: term.h: No such file or directory

In Ubuntu, just install the ncurses-dev.

Thursday, September 02, 2010

Converting filenames from UPPERCASE to lowercase

I searched and found the following thread:
http://blog.mc-thias.org/?title=rename-files-from-upper-case-filename-to&more=1&c=1&tb=1&pb=1

Based on the post given by Jadu Saikia, I got the bash script of my own version as follows:
ls * | sed -e p -e 's/.*/\L&/g' |xargs -n 2 mv

One new thing I've learned in this example is the ``\L'' part, which can be found in sed's FAQ.