Informatica Reference

How to check the length of any line in a file?

Posted on: 12/21/2011

We already know how to print one line from a file which is this:

$> sed –n ‘<n> p’ file.txt

Where <n> is to be replaced by the actual line number that you want to print. Now once you know it, it is easy to print out the length of this line by using [wc] command with ‘-c’ switch.

$> sed –n ’35 p’ file.txt | wc –c

The above command will print the length of 35th line in the file.txt


Get every new post delivered to your Inbox.

Join 70 other followers

%d bloggers like this: