Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding lines which are greater than 120 characters length using sed

Tags:

sed

I want to get a list of lines in a batch file which are greater than 120 characters length. For this I thought of using sed. I tried but I was not successful. How can i achieve this ? Is there any other way to get a list other than using sed ?? Thanks..

like image 959
Sravan Avatar asked Oct 10 '12 08:10

Sravan


People also ask

Which of the below commands can be used to display lines longer than 100 characters and smaller than 150 characters in a file using grep?

The -n option will prevent to print anything unless an explicit request to print is found ( ^. {101,149}$ "Lines longer than 100(>=101) and smaller than 150 characters(<=149)"). The /p flag used as one way to turn printing back on. The -r enables the Extended regular expressions.


2 Answers

Another way to do this using awk:

cat file | awk 'length($0) > 120'
like image 141
piokuc Avatar answered Oct 19 '22 00:10

piokuc


You can use grep and its repetition quantifier:

grep '.\{120\}' script.sh
like image 35
choroba Avatar answered Oct 19 '22 02:10

choroba