Suppress last N lines printing


 
Thread Tools Search this Thread
Top Forums Programming Suppress last N lines printing
# 1  
Old 11-12-2003
Suppress last N lines printing

Hi,

I want to know different ways of suppressing printing of last N lines.

Can anyone help?

Thanks,
Sree
# 2  
Old 11-12-2003
This is pretty vague.. you'll have to be a lot more specific for anyone to give you a meaningful answer! Smilie If you want to display a the first n lines at the beginning of the file, look into the head command. It doesn't look like this is what you want though, but it'd more helpful to know exactly what you're trying to do.

------
There's probably a nice short way to do this, but a short script like this would work:

linesToSkip=10
b=`wc -l < yourFile`
head -n `expr $b - $linesToSkip` yourFile

Last edited by oombera; 11-12-2003 at 02:37 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Python: Suppress lines not substituted

Hi all, I started playing around with Python (2.6.6) trying to parse a file. No matter what I tried so far I am not able to print only the lines/group/backreference that have been affected by the substitution. Instead I get also the other lines too File to parse: some more text ... (2 Replies)
Discussion started by: zaxxon
2 Replies

2. UNIX for Dummies Questions & Answers

Printing out lines that have the same value in the first column but different value in the second

Hi, I have a text file that looks like the following: ILMN_1343291 6 74341083 74341772 ILMN_1343291 6 74341195 74341099 ILMN_1343295 12 6387581 6387650 ILMN_1651209 1 1657001 1657050 ILMN_1651209 5 83524260 83524309 I... (1 Reply)
Discussion started by: evelibertine
1 Replies

3. Shell Programming and Scripting

printing lines before and after a record

Hello Everyone, I want to print out the records after and before a certain record. I am able to figure out how to print that particular record but not the ones before and after. Looking for some advice Thank you (6 Replies)
Discussion started by: danish0909
6 Replies

4. Shell Programming and Scripting

Printing the lines that appear in an other file, and the three lines after them

Hi ! I need some help with a script I am writing. I am trying to compare two files, the first file being in this format : Header1 Text1-1 Text1-2 Text1-3 Header2 Text2-1 etc... For each header, I want to check if it appears in the second file, and if it is the case print the header... (4 Replies)
Discussion started by: jbi
4 Replies

5. UNIX for Dummies Questions & Answers

Tool to suppress lines where value=0

Hello everyone, Here's the problem, I have a list generated by this command; watch -n 5 'iptables -nvL | grep "DROP"' It generates output that looks like this (severely truncated for clarity) Every 5.0s: iptables -nvL | grep "DROP" ... (2 Replies)
Discussion started by: putter1900
2 Replies

6. Shell Programming and Scripting

fgrep not printing non matching lines

I'm using this: fgrep -f file1.txt file2.txt To find lines in file1 that match patterns found in file2. When I add -v: egrep -v -f file1.txt file2.txt It won't return non matching lines, I just get a blank. Can anyone help? PS. file1.txt contains 3 million lines...each string... (2 Replies)
Discussion started by: Nonito84
2 Replies

7. Shell Programming and Scripting

Printing all lines before a specific string and a custom message 2 lines after

Hello all, I need to print all the lines before a specific string and print a custom message 2 lines after that. So far I have managed to print everything up the string, inclusively, but I can't figure out how to print the 2 lines after that and the custom message. My code thus far is:... (4 Replies)
Discussion started by: SEinT
4 Replies

8. Shell Programming and Scripting

Printing coloured lines

I want to print "Hello,How are you" in green colour using printf. How to do so? (5 Replies)
Discussion started by: proactiveaditya
5 Replies

9. Shell Programming and Scripting

selective printing of lines

Hi all , i need to grep for a string in a text file and print the string and the 3rd line above it. As always , Thanks. (4 Replies)
Discussion started by: okiedokie
4 Replies

10. Shell Programming and Scripting

Printing specified lines only

hi, i m having 2 files say F1 and F2. there are some joining conditions like: Column 4 from F1= Column 29 from F2; Column 10 from F1= Column 165 in F2; and if value in column 8 from F2='3' than i should get Column 4,5,8,10 from F1 and 29,165 from F2. I cant provide the files. but the... (4 Replies)
Discussion started by: Mohit623
4 Replies
Login or Register to Ask a Question