LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-11-2010, 05:28 AM   #1
hurryi
Member
 
Registered: Apr 2010
Distribution: RHEL
Posts: 77

Rep: Reputation: 7
how to remove X lines from output


Hello,

I would like to know how to remove X lines from output.

lets say i have a test file and i want the output without the first 2 lines

[root@node1 ~]# cat test
1
2
3
4
2
1


maybe it is very easy but i could not find the solution.

Thanks in advance.
 
Old 10-11-2010, 05:32 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,423

Rep: Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823
Quote:
but i could not find the solution.
So you have searched extensively and found nothing? I find this a little hard to believe.

How about http://www.lmgtfy.com/?q=how+to+remo...es+from+output
 
Old 10-11-2010, 05:35 AM   #3
angel115
Member
 
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 532

Rep: Reputation: 78
Try this:
Code:
cat test | awk 'NR > 2'
PS: Mark you post as solved if it is.

Last edited by angel115; 10-11-2010 at 05:37 AM.
 
Old 10-11-2010, 05:37 AM   #4
hurryi
Member
 
Registered: Apr 2010
Distribution: RHEL
Posts: 77

Original Poster
Rep: Reputation: 7
lol, right i found solution with grep -v or nl and grep -v but it wont work with this file because i want to reduce the first 2 lines exactly not with some filters as the real file data is changing
maybe if there would be an option like grep -v with head -v
 
Old 10-11-2010, 05:38 AM   #5
hurryi
Member
 
Registered: Apr 2010
Distribution: RHEL
Posts: 77

Original Poster
Rep: Reputation: 7
Quote:
Originally Posted by angel115 View Post
Try this:
Code:
cat test | awk 'NR > 2'
PS: Mark you post as solved if it is.
awk alright thanks
 
Old 10-11-2010, 06:40 AM   #6
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by angel115 View Post
Try this:
Code:
cat test | awk 'NR > 2'
PS: Mark you post as solved if it is.
useless use of cat
Code:
awk 'NR>2' test
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to remove over written lines MrUmunhum Linux - General 2 04-19-2010 05:58 PM
How to remove lines and parts of lines from python strings? golmschenk Programming 3 11-27-2009 12:29 AM
Remove Blank Lines wwnexc Linux - Software 2 05-06-2006 12:14 PM
How to remove lines from a file doza Linux - General 2 04-27-2005 12:59 PM
how to remove all commented lines win32sux Linux - General 11 05-08-2004 04:27 AM


All times are GMT -5. The time now is 10:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration