i find this one that really works its output me the correct line and everything...
but each time i need to go and change the filename in order to find what i want...
This expects the date as the first parameter, and a list of files as the remaining parameters. Those are passed through to awk in "$@" after the first argument (the date) has been shifted off and passed to the awk script as a variable.
I took out the { print } because that is the default action; this is probably less readable, so if you don't use awk much, it might be safer to leave it in.
Of course, this simple script is exactly equivalent to grep without any options or other bells & whistles.
Last edited by era; 04-20-2008 at 01:45 PM..
Reason: Fix case statement to accept more than one file, duh
but i am afraid this does not work.
i think that in the script that u write it checking throught files date..
what i want is to check throught files text content...
i have the traffic of my website... in a directory named traffic...
the traffic directory have files with each webpage ip that visit my website!!
so i want the script to be able to output me the ips that visit my website the date that i ask...
What's the syntax error? And why did you add the "read vardate" stuff? You're supposed to pass in the date on the command line. Of course, you can change that, but then you need to modify the rest of the script accordingly.
When passing a value with spaces in it, you need to use quotes:
Here's another try at a script:
The script will be more useful for use from other scripts if you let it accept the date on the command line rather than read it interactively, but that may not be an issue here. Anyway, you need to pass it the file(s) to search as arguments anyway, so why not make the date a command-line argument, too (or else ask which files to grep, interactively).
Hi,
I want to pull lines between two timestamps from a file. When I just insert values directly it is working fine.
sed -n '/2014-02-14 05:30/,/2014-02-14 05:31/p' Logfile
When I try to insert variable it is not working.
sed -n '/TZ=GMT+1 date +%Y-%m-%d" "%H:%M:%S/,/TZ=GMT date... (2 Replies)
Hi
I am looking for a help in designing a bash script on linux which can do below:-
1) Look in a specific directory for any new files
2) Mail the content of the new file
Appreciate any help
Regards
Neha (5 Replies)
Hi All,
below script reads the perticular files from the directory. Am trying to fetch status and print them in the required format.
It needs to read line and search for string "Passed/Failed" and print them under correct sub header.
script :
BASE_DIR=/tmp/test/REPORT/CollectReport
#... (16 Replies)
I have a log file where every line starts with a time stamp. I have to extract lines from the file within a given time stamp.
For example:
IF the file is like this:
2012-08-19 10:34:03,446|WebContainer : 56|OrderHeaderDaoImpl|findByKeys|26|
2012-08-20 11:34:03,463|WebContainer :... (8 Replies)
I need a Shell script which take two inputs which are
1) main directory where it has to search and
2) pattern to search within main directory all files (.c and .h files)
It has to print number of pattern found in main directory & each sub directory.
main dir --> Total pattern found = 5
|... (3 Replies)
Have to read one file say sourcefile containing several words and having another folder containing several files.
Now read the first word of Sourcefile & search it into the folder consisting sevral files, and create another file with result. We hhave to pick the filename of the file in which... (3 Replies)
How can I remove all data that contain domain e.g zzgh@something.com, sdd@something.com.my and gg@something.my in one file? so that i only have data without the domain in the file.
Here is the file structure "test.out"
more test.out
1 zzztop@b.com
1 zzzulll
1 zzzullll@s.com.my
... (4 Replies)
Hello,
How to search in directory by comparing some string with the content of
directory.
Ex:
I want to compare abhi string with the content of backup directory.
i.e want to check that is there any file in backup directory having name
... (3 Replies)
Hi,
I've a shell script e.g.
#!/bin/bash
echo "Enter the next hop id"
read nhid
echo "enter the IP address"
read IP
echo "enter the interface name"
read name
echo "enter the enable/disable state"
read state
exit 0
now from this script i want to search strings in another (.cam)
... (6 Replies)
Hi
I need some help using shell script to edit a file.
My original file has the following format:
/txt/email/myemail.txt
/txt/email/myemail2.txt
/pdf/email/myemail.pdf
/pdf/email/myemail2.pdf
/doc/email/myemail.doc
/doc/email/myemail2.doc
I need to read each line. If the path is... (3 Replies)