04-10-2010
time?
you want it to print the word "time" or the actual time of day? (11:09pm) I dont know if grep has an option like that. You might have to combine it with something like awk.
#more file1.txt
this is line 1 red
this is line 2 orange
this is line 3 yellow
this is line 4 green
this is line 5 blue
this is line 6 purple
this is line 7 blue
this is line 8 red
this is line 9 blue
this is line 10 red
So perhaps you want to grep for the lines with "blue" in them. what do you want your output to look like?
example output
#./script
11:20am this is line 5 blue
11:20am this is line 7 blue
11:20am this is line 9 blue
btw I am just writing this reply to see if i got your question correct. I'm sure theres a very elegant way to do this. Your answer will come shortly I'm sure. People here are VERY good!
---------- Post updated at 01:42 PM ---------- Previous update was at 01:23 PM ----------
or perhaps yoru input file already has the times and you are looking for specific times? example
#more file1.txt
11:30am this is line 1
11:30pm this is line 2
11:00am this is line 3
11:00pm this is line 4
11:30am this is line 5
11:40pm this is line 6
11:30am this is line 7
and you want your output to only print the 11:30am lines?
Just trying to be as specific as possible so others can get you exactly the help you need.
Last edited by ajp7701; 04-10-2010 at 03:33 PM..
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
How do I use the grep command to take mutiple text files in a folder and make one huge text file out of them. I'm using Mac OS X and can not find a text tool that does it so I figured I'd resort to the BSD Unix CLI for a solution... there are 5,300 files that I want to write to one huge file so... (7 Replies)
Discussion started by: coppertone
7 Replies
2. UNIX for Dummies Questions & Answers
Hi
I have two files a1 and b1
a1 has the following job names
ab
cd
ef
b1 has the following job details
/*----------- ji -----------------*/
asdasd fgd
saas dfdf
asas fd gfg
/*---------- ab ----------------*/
ara jhk
dfhk asjla
condition: s(abc_wf_hi) (10 Replies)
Discussion started by: napolayan
10 Replies
3. Shell Programming and Scripting
Hi all,
I need to grep a line from a log file which ensures me that the application server script is executed successfully. Some body please help me on this.
I also need to write a while loop in which i need to use the status of the above grep output. Could some one please tell me how to use... (12 Replies)
Discussion started by: firestar
12 Replies
4. Shell Programming and Scripting
Hi. I have a unix script 'if' condition that greps through a file and searches for the strings ERROR and WARNING.
if egrep -q 'ERROR|WARNING' myfile.txt; then
When this 'if' condition is true then I want to be able to capture 10 lines before the string and 10 lines after the string. So... (6 Replies)
Discussion started by: buechler66
6 Replies
5. Shell Programming and Scripting
Hello friends!
Help me pls to write correct awk and grep statements for my task:
I have got files with name filename.txt
It has such structure:
Start of file
FROM: address@domen.com (12...890) abc
DATE: 11/23/2009 on Std
SUBJECT: any subject
End of file
So, I must check,
if this file... (4 Replies)
Discussion started by: candyme
4 Replies
6. Shell Programming and Scripting
Hi,
I used the grep command and got the result below.
However, I just want the following information:
Build Version:
DnETest Build
Build Date-Time:
01/27/2012 07:56:14 AM
Any suggestion from the current out put I have:
<td><span class="style29"> Build Version: </span></td>... (1 Reply)
Discussion started by: xitrum
1 Replies
7. UNIX for Dummies Questions & Answers
I would like to use grep to select multiple lines from a text file using a single-column text file. Basically I want to only select lines from the first text file where the second column of the first text file matches the second text file. How do I go about doing that? Thanks! (5 Replies)
Discussion started by: evelibertine
5 Replies
8. Shell Programming and Scripting
Hello,
I want to grep a log ("server.log") for words in a separate file ("white-list.txt") and generate a separate log file containing each line that uses a word from the "white-list.txt" file.
Putting that in bullet points:
Search through "server.log" for lines that contain any word... (15 Replies)
Discussion started by: nbsparks
15 Replies
9. Linux
Hi all,
We Have Squid server, We need to get the particular IP's log from /var/log/squid/access.log, if i need to get only the log's of 192.168.0.99, How can i get the log's to a separate file.
Here is the sample log what i have got from access.log file
1392706763.690 847... (2 Replies)
Discussion started by: babinlonston
2 Replies
10. Shell Programming and Scripting
My current line command is as follows:
echo -n "text: " ; grep "blah text" ../dir1/filename | wc -l
The output to the screen is as needed, but how do I print to a text file? (9 Replies)
Discussion started by: ncwxpanther
9 Replies
ZGREP(1) BSD General Commands Manual ZGREP(1)
NAME
zgrep, zegrep, zfgrep -- print lines matching a pattern in gzip-compressed files
SYNOPSIS
zgrep [grep-flags] [--] pattern [files ...]
zegrep [grep-flags] [--] pattern [file ...]
zfgrep [grep-flags] [--] pattern [file ...]
DESCRIPTION
zgrep runs grep(1) on files or stdin, if no files argument is given, after decompressing them with zcat(1).
The grep-flags and pattern arguments are passed on to grep(1). If an -e flag is found in the grep-flags, zgrep will not look for a pattern
argument.
zegrep calls egrep(1), while zfgrep calls fgrep(1).
EXIT STATUS
In case of missing arguments or missing pattern, 1 will be returned, otherwise 0.
SEE ALSO
egrep(1), fgrep(1), grep(1), gzip(1), zcat(1)
AUTHORS
Thomas Klausner <wiz@NetBSD.org>
BSD
December 28, 2003 BSD