Skip to content

Tag: wc

How to get lines of a file with exactly 3 characters in Linux

I need a command to find the lines of a file that have 3 characters. I do the command wc -w field.txt to list how many lines, but now I need to know the lines with 3 characters, exactly. Answer This will count (-c) the number of lines which match the regex (-E) “^.{3}$”, which is “start of l…