Print file with line number, line lenght and starting line


/ Published in: Java
Save to your folder(s)

This is useful to view files with long lines like MySQL dumps.

Example output: line, lenght, first characters (as defined in `substr`)

1 19 -- MySQL dump 10.11
2 2 --
3 36 -- Host: localhost Database: live
4 57 -- ------------------------------------------------------
5 40 -- Server version 5.0.51a-3ubuntu5.4-log
6 0
7 65 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
8 67 /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
9 65 /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
10 27 /*!40101 SET NAMES utf8 */;


Copy this code and paste it in your HTML
  1. awk '{ printf "%5s %8s %s\n", NR, length($0), substr($0,0,180); }' file

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.