LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-10-2007, 07:56 PM   #1
xnomad
Member
 
Registered: Jun 2005
Posts: 53

Rep: Reputation: 15
grep output on stdout and grep output to file don't match


Hi when I grep a log file e.g

grep pattern /var/log/something

I get the full line of text line for line.

Now if I do

grep pattern /var/log/something > outputFile

The lines in the output are truncated there are words in the middle missing.

Any idea why redirecting the output to a file truncates the output?

I tried the following as well and this didn't work either:

grep pattern /var/log/something 2>&1 > outputFile

and if I do

grep -C 1 pattern /var/log/something > outputFile

I get more than I want in the file although it does include what I need.

Any ideas?
 
Old 01-11-2007, 05:17 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Interesting.
What distro+release?
What grep version?
Do you use a grep alias?
Bash completion?
Modified IFS?
Any characteristics missing words share?
Can you give an example of an output line and mark where word or words are missing?
 
Old 01-12-2007, 03:39 PM   #3
xnomad
Member
 
Registered: Jun 2005
Posts: 53

Original Poster
Rep: Reputation: 15
Sorry everyone please ignore my original post!


Turns out that the developers had turned on a more verbose output on the log only recently so not all the log had the same detail.

When greping without an output file I would see the bottom of the log where the verbose information was. When greping to a file and opening it in vi I would see the top of the file where the verbose output wasn't there. Of course if I had bothered to scroll down half way the verbose logging would have appeared.

I'm really sorry for waisting anyone's time!
 
Old 01-13-2007, 04:56 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
NP, at least thanks for posting who the culprits are...
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Grep command for the following output minil Programming 2 12-29-2005 07:49 AM
Need Grep command for the following output minil Programming 1 12-29-2005 06:51 AM
output to a file - cat? grep? Godsmacker777 Linux - Newbie 6 12-08-2004 10:06 AM
sort grep output wijnands Linux - Newbie 4 10-09-2004 07:14 AM
trying to figure out some output from grep naijaguy Linux - Newbie 8 08-17-2004 12:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:06 PM.

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
Open Source Consulting | Domain Registration