The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How can i read a non text file in unix - ELF-64 executable object file - IA64 alexcol UNIX for Advanced & Expert Users 8 11-07-2008 08:56 AM
how to read all the unique words in a text file aditya.ece1985 Shell Programming and Scripting 5 11-30-2007 02:26 AM
read specific text from a log file ragha81 Shell Programming and Scripting 4 10-17-2006 01:17 PM
appending string to text file based on search string malaymaru Shell Programming and Scripting 1 06-09-2006 08:53 AM
need to read 3° character from a text file piltrafa UNIX for Dummies Questions & Answers 15 07-26-2005 10:19 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-08-2008
bsrajirs bsrajirs is offline
Registered User
  
 

Join Date: May 2007
Posts: 11
Read text file from a specified string to the end

Hi All,

I like to read the log file from specific time to end of the file.

eg:
message
date and time
message 1
date and time1
message 2
EOF

I want to read all the text (Messages) after date and time to end of the file.
Please let me know the UNIX command to perform this?.

Thanks,
bsraj.
  #2 (permalink)  
Old 01-08-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,509
awk
Code:
awk '/date and time/{f=1}f' file
shell
Code:
while read line
do
 case $line in
 "date and time" ) f=1;; 
 esac
 if [ $f -eq 1 ];then
   echo "$line"
 fi
done < "file"
  #3 (permalink)  
Old 01-08-2008
bsrajirs bsrajirs is offline
Registered User
  
 

Join Date: May 2007
Posts: 11
Hi,

Thanks for your response.
I tried to using the shell script, but i am getting error because there are spaces in between the data and time.
Can we able to get all the lines from the logfile after this string "2008 01 01 12:00:00"?.

Thanks,
bsraj
  #4 (permalink)  
Old 01-09-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,509
show how your code.
  #5 (permalink)  
Old 01-09-2008
bsrajirs bsrajirs is offline
Registered User
  
 

Join Date: May 2007
Posts: 11
Hi,

Please find my sample code..

#! /bin/ksh
set -x

LogFile="/tmp/scan_log.log"
LoadFile="/tmp/new_scan_log.log"
Last_Alert="Alert: Fri Jan 4 16:15:01 2008"

while read line
do
case $line in
"$Last_Alert" ) f=1;;
esac
if [ $f -eq 1 ]; then
echo "$line" >> $LoadFile
fi
done < "$LogFile"

Thanks,
bsraj
  #6 (permalink)  
Old 01-09-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,509
what's your result with awk version?
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:25 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0