rodrigosantosbr

show lines longer than X characters

Feb 17th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!

Here's a quick little awk trick to have in your arsenal: if you want to search through a bunch of files, but only want to show the lines that exceed X amount of characters, you can use awk's built-in length check.

For instance:

$ awk 'length > 350'
$ awk 'length < 50' 

If you combine this with a grep, you can do things like "show me all the lines that match TXT and that exceed 100 characters in length".

$ grep 'TXT' * | awk 'length > 100'

Super useful to quickly skim through a bunch of logs or text-files.

Add Comment
Please, Sign In to add comment