Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 5580  / 2 Years ago, wed, april 6, 2022, 11:08:54

So for example, I have this text file:



use
user_99
12345


+10k lines...



And I want to remove those that have less than 4 characters from the command line,
I've already searched in google but no results came.



Any ideas? : )



I'd also like to remove lines with more than 3 numbers in the beginning.


More From » bash

 Answers
6

sed or awk are good choices:



sed -rn '/^.{0,3}$/n; /^[0-9]{3,}/n; p' file

awk --re-interval 'length > 3 && !/^[0-9]{3,}/' file

[#26567] Friday, April 8, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
quivedge

Total Points: 223
Total Questions: 116
Total Answers: 124

Location: Slovenia
Member since Wed, Apr 6, 2022
2 Years ago
;