Posts Tagged ‘cat’

print the content of a file with line numbers

November 4, 2013 Leave a comment
cat -n file.txt
Categories: bash Tags: ,

Syntax-highlighted “cat” in command line

May 29, 2013 1 comment

You have a source code whose content you want to display on the stdout. The natural way to do that is the “cat” command but it’s monochrome. How to get a syntax-highlighted output?

Use pygments. If you install it (“sudo apt-get install python-pygments“), you will have a command called “pygmentize” that you can invoke from the command line.


pygmentize -f terminal256 -O style=native -g

Tip: put an alias on it.

alias pcat="pygmentize -f terminal256 -O style=native -g"

There are different styles available, see “pygmentize -L” for a list.

Tip from here. Discussion @reddit here.


Jabba the Cat

March 21, 2011 Leave a comment

Jabba the Cat #1

But where is Princess Leia?!


Jabba the Cat #2

Split a large file

October 27, 2010 Leave a comment


You have a large file and you want to split it up in several pieces of the same size.


Let’s say we want pieces of 50,000,000 bytes (50 MB approximately).

split --bytes=50000000 film.avi

By default, the output files are named as ‘xaa‘, ‘xab‘, ‘xac‘, etc., where ‘x‘ is the prefix and ‘aa‘, ‘ab‘, ‘ac‘, etc. are the suffixes.

Use the command cat to put them together:

cat xaa xab xac >out.avi

Or simply:

cat x* >out.avi


split --bytes=50000000 -d film.avi pre-

Now the pieces will be named as pre-01, pre-02, etc. The switch -d means to use numeric suffixes.

One more:

split --bytes=50m -d film.avi pre-

Now the size of the output pieces is really 50 MB, i.e. 52,428,800 bytes.

Categories: bash Tags: ,