Find Lines Longer than Specified Length

When editing data files, sometimes you need to find the lines that are longer or shorter than a certain length to make corrections. However when a data files has several hundred thousand or millions of rows, this can be a very time consuming task. The way to accomplish this is to use "awk".

awk is a program that is often used for parsing and processing data into readable chunks. An example would be reading a CSV file into a script to display a particular output.

What is the command:

awk 'length($0)>50' datafile.txt

Breaking down the command we have:

awk

This is the program that we are running

'length($0)>50' 

This is the argument that is passed to the program.

I enjoy sharing the content that you find here. I ask that you consider purchasing an item on my Amazon Wish List or you can make a donation.

Back To Top