Find lines greater than 80 characters in a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find lines greater than 80 characters in a file
# 1  
Old 03-09-2007
Find lines greater than 80 characters in a file

Hi,
Can anyone please give me the grep command to find all the lines in a file
that exceed 80 columns

Thanks,
gubbala
# 2  
Old 03-09-2007
Code:
awk -F<delimiter> ' NF > 80 { print } ' filename

or just this
Code:
awk -F<delimiter> ' NF > 80  ' filename


Last edited by vgersh99; 03-09-2007 at 09:15 AM..
# 3  
Old 03-09-2007
sed -n '/\(.\)\{80\}/p' filename
# 4  
Old 03-09-2007
Quote:
Originally Posted by jacoden
sed -n '/\(.\)\{80\}/p' filename
This commands works out for 80 chars length of a line
and the OP had requested for lines greater than 80 columns ! Smilie
# 5  
Old 03-09-2007
Bug

Hi Matrixmadhan,

Have a look at this..It works well when I tested..

u142115@linux2alm:~/aps/aps4/product/den/dennis/test> awk '{print length($0)" "$0}' ne
36 gagkasdadsgfkdaskdgkagsdkgkasgdkgasd
8 assddasd
4 aaas
4 sddd
6 asasas
5 asddd
2 sa
9 saddasdas
2 sd
u142115@linux2alm:~/aps/aps4/product/den/dennis/test> sed -n '/\(.\)\{5\}/p' ne
gagkasdadsgfkdaskdgkagsdkgkasgdkgasd
assddasd
asasas
asddd
saddasdas
u142115@linux2alm:~/aps/aps4/product/den/dennis/test>


advise me if something wrong here...as I am a newbie in Unix..
# 6  
Old 03-09-2007
with GNU grep
Code:
grep  '.\{80,\}' file

# 7  
Old 03-09-2007
Well possibly I could be wrong!

Meaning of columns is ambiguous here Smilie

What i meant is,
Code:
c1 <delimiter> c2 <delimiter> c3 ... <cn>

literal meaning of column as such being delimited by some delimiter ( including the default delimiter as well )

Its OP who should correct us, giving the meaning of columns here,

whether is 80 chars in a line or
columns as I had said .

Till OP clears it, I had to get back my statement that your command is wrong.

Am sorry about that ! Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find all lines in file such that each word on that line appears in at least n lines of the file

I have a file where every line includes four expressions with a caret in the middle (plus some other "words" or fields, always separated by spaces). I would like to extract from this file, all those lines such that each of the four expressions containing a caret appears in at least four different... (9 Replies)
Discussion started by: uncleMonty
9 Replies

2. Shell Programming and Scripting

Breaking lines which contains more than 50 characters in a file

Hi, I have a file which contains many lines. Some of them are longer than 50 chars. I want to break those lines but I don't want to break words, e.g. the file This is an exemplary text which should be broken aaaaaa bbbbb ccccc This is the second line This line should also be broken... (3 Replies)
Discussion started by: wenclu
3 Replies

3. Shell Programming and Scripting

Find out match characters on all lines

I have a file with 22 lines. Each line has only 5 different chars, no white space, and each line is 3,278,824 in length. The 5 chars is "-", "A", "B", "C", "D". Below is an example of the first 25 chars of the first four lines of the file. -----ABCDA--CD-BBBBB----D --A--ABCD--DCD-BBBBC-----... (12 Replies)
Discussion started by: cwzkevin
12 Replies

4. Shell Programming and Scripting

Need to find lines where the length is less than 50 characters

Hi, I have a big file say abc.csv. And in that file, I need to find lines whose length is less than 50 characters. How can it be achieved? Thanks in advance. Thanks (4 Replies)
Discussion started by: Gangadhar Reddy
4 Replies

5. Shell Programming and Scripting

Select lines in which column have value greater than some percent of total file lines

i have a file in following format 1 32 3 4 6 4 4 45 1 45 4 61 54 66 4 5 65 51 56 65 1 12 32 85 now here the total number of lines are 8(they vary each time) Now i want to select only those lines in which the values... (6 Replies)
Discussion started by: vaibhavkorde
6 Replies

6. UNIX for Dummies Questions & Answers

Display only the first two characters of all the lines from a file.

how do i Display only the first two characters of all the lines from a file.? (1 Reply)
Discussion started by: ritusubash
1 Replies

7. UNIX for Dummies Questions & Answers

Print lines which are greater than

I have a file which has a list of titles and then 14 lines afterwards. I need to find the 1 through 14 lines which are greater than 15k and print the title and the line which matched. Sample before: ABC.CDE.NORTH.NET 1:18427 2:302 3:15559 4:105 5:5 6:2 7:2 8:2 9:4 10:2 11:17 12:2... (3 Replies)
Discussion started by: numele
3 Replies

8. Shell Programming and Scripting

find lines have 2nd colum value greater than 40

i have a file a.txt 12345,20 34567,10 23123,50 123456,45 how to find lines which hav 2nd entry greater than 40 o/p 23123,50 123456,45 pls help to get o/p (5 Replies)
Discussion started by: devesh123
5 Replies

9. Shell Programming and Scripting

Can I find wether a particular file exist and size greater than zero...help please

Can I find wether a particular file exist and size greater than zero in one line command. similar to this if && something in one if test .... e.g. if 1.) is it possible ? ... if yes how 2.) what would be the return type in case there is success or failure. I mean if both are... (4 Replies)
Discussion started by: guhas
4 Replies

10. UNIX for Advanced & Expert Users

how to remove line greater then 3000 characters.

I am using awk and it stops when it encounter line greater then 3000 character. Is there any command which will help me remove line greater then 3000 characters. (10 Replies)
Discussion started by: naren_14
10 Replies
Login or Register to Ask a Question