Sponsored Content
Top Forums Shell Programming and Scripting grep return more than one line Post 302453833 by a27wang on Thursday 16th of September 2010 01:40:55 PM
Old 09-16-2010
grep return more than one line

Hi,

I have a lot of log files which contain lines in the format of (date info) or (info), and when I use grep to search for "date" I was able to get the (date info) line, but some info lines are a separate line after the (date info) line... for example like:

(date info info info)
(date info info)
(info info)
(date info) (or end of file)
I want grep to return the date info line and any further info lines containing the date parameter i enter.

any help would be greatly appreciated, thanks.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

grep for a line then return lines above

Hey guys, I just want to grep for a line then return a few lines above it I can't seem to find what im looking for on google can someone help me out? This is on Solaris 9..... I don't have GNU grep so -B and -A commands will not work (3 Replies)
Discussion started by: kingdbag
3 Replies

2. Shell Programming and Scripting

problem in the return of grep

hi, i am running this command inside the script var=`grep -il $1 "${logdir}"* | xargs grep -ivl adding | xargs grep -ivl equation | xargs ls -ctr | tail -1` in that grep will find the latest logfile for the variable "$" if it fnd the logfile, then it reutrns the filename to the var if... (1 Reply)
Discussion started by: mail2sant
1 Replies

3. Shell Programming and Scripting

modifying grep to return latest files

Hi guys, I currently use the below mwntioned grep statemen to get the timestamp of the last generated file in the directory. (ls -ltr eCustomerCME* | grep ^- | tail -1 | awk ' { print $6,$7,$8 } ') I need to modify this grep to search for files generated only within last 2 hrs. Can you pls... (5 Replies)
Discussion started by: ragha81
5 Replies

4. UNIX for Dummies Questions & Answers

| help | unix | grep - Can I use grep to return a string with exactly n matches?

Hello, I looking to use grep to return a string with exactly n matches. I'm building off this: ls -aLl /bin | grep '^.\{9\}x' | tr -s ' ' -rwxr-xr-x 1 root root 632816 Nov 25 2008 vi -rwxr-xr-x 1 root root 632816 Nov 25 2008 view -rwxr-xr-x 1 root root 16008 May 25 2008... (7 Replies)
Discussion started by: MykC
7 Replies

5. UNIX for Dummies Questions & Answers

Can grep command return word instead of complete line

Hi Is there any way GREP command can return word and not complete line. My file has following data: Hello Everyone I am NitinrajSrivastava Hi Friends Welcome VrajSrivastava I am using grep 'raj' which is returning me complete line.However I want only the word having keyword 'raj'. Required... (11 Replies)
Discussion started by: dashing201
11 Replies

6. UNIX for Advanced & Expert Users

return of grep

Hi, in a script I will do : grep ORA- mylogfile.log If it returns any ORA- (oracle error) I whant to have : echo "subject : RMAN in Error " >> /appli/rap.txt But if no error echo "subject : RMAN OK " >> /appli/rap.txt Can you help me ? The grep return code would it be... (1 Reply)
Discussion started by: big123456
1 Replies

7. Shell Programming and Scripting

Grep: Return a user message when no hits

I have ASCII files to parse that 48 hours old or more ; I can identify them like so find . -name "FILE*TXT" -mtime +1 -exec ls -ltas '{}' ';' Some files have a list of hardware errors (we test electronic components), some have none. If the file name has no errors, I still want to... (3 Replies)
Discussion started by: alan
3 Replies

8. UNIX for Dummies Questions & Answers

Grep to return lines not containing a character

Hello , this is my first topic cause I need your little help:( I got .txt file, and I want to find lines without letter 'a', so im writing: grep "" list.txt (list.txt is the file of course) and i have no idea why it's not working because it shows lines with a. (1 Reply)
Discussion started by: bbqtoss
1 Replies

9. Shell Programming and Scripting

search a string in a particular column of file and return the line number of the line

Hi All, Can you please guide me to search a string in a particular column of file and return the line number of the line where it was found using awk. As an example : abc.txt 7000,john,2,1,0,1,6 7001,elen,2,2,0,1,7 7002,sami,2,3,0,1,6 7003,mike,1,4,0,2,1 8001,nike,1,5,0,1,8... (3 Replies)
Discussion started by: arunshankar.c
3 Replies

10. Shell Programming and Scripting

Return line when line below has the string

I have a file with data like this. I want to look for MultiLoad and pull that line and the line above. I cant use the grep -B 1 I dont have that version and cant install on the server. is there a awk or perl that will do it. "CMPGN_RPT_DEV_TT"."text1" (TableId 0029H 5CEEH) bypassed due to... (4 Replies)
Discussion started by: wambli
4 Replies
avbdiagnose(1)						    BSD General Commands Manual 					    avbdiagnose(1)

NAME
avbdiagnose -- diagnostic tool for AVB. SYNOPSIS
avbdiagnose DESCRIPTION
The avbdiagnose tool is used to capture a snapshot of the current AVB system state and help diagnose common issues with AVB. avbdiagnose looks for the system to determine that it actually has AVB capable interfaces and that at least one of these has been enabled. avbdiagnose will produce a number of warnings which may not be errors depending on the setup of the system. Things such as missing local or remote attributes for MSRP will be flagged as a warning but is not an error if the Mac is not sourcing or sinking streams as appropriate for the warning. avbdiagnose will flag potential errors and warnings and suggest filing a radar report at http://bugreporter.apple.com. Please attach the generated file at /tmp/avbdiagnose-<date>.bz2 to the bug report. An error or warning report may be the result of a network device. Please use your best judgement before filing the bug report. The following options are available: --no-enumeration Disable the reading of the AVDECC AEM from the device and archiving it in the result. --no-coreaudio Disable dumping of the state of the AVB audio driver device tree. --acmp-state Enabled reading of and dumping the ACMP state of the entities. --stream-info Enable sending of the AVDECC AECP AEM GET_STREAM_INFO command to each of the possible stream sources and sinks and including in the info dump. --stream-counters Enable sending of the AVDECC AECP AEM GET_COUNTER command to each of the possible stream sources and sinks and including in the info dump. --no-info-tree Disable dumping of the state of the AVB info tree. --no-timesync Disable dumping of the state of the Time Sync info tree. FILES
/tmp/avbdiagnose-<date>.bz2 output The information gathered by avbdiagnose including the command line output, an ioreg dump and the current system.log and kernel.log files. Darwin May 31, 2019 Darwin
All times are GMT -4. The time now is 11:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy