I have a file.txt
fhadja
ksjfskdasd
adasda
sada
s
adasaaa
I need to extract only the words that are 6 character length from there.
EXAMPLE of what i need to obtain as a result:
fhadja
adasda
Thank you.
You can use:
grep -E '^.{6}$' file
fhadja
adasda
Or using awk:
awk 'length($0)==6' file
fhadja
adasda
Or using sed
:
sed -rn '/^.{6}$/p' file
fhadja
adasda
Try this with GNU grep:
grep -E '^.{6}$' file
Output:
fhadja adasda
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With