Your greps need some escaping. Right now the . means 'match any character', not 'match .'
And your greps won't return anything because first you reject everything except your start time, and after that you reject everything except your end time. You need to match start and end and everything inbetween. Since grep doesn't understand what date and time means -- or what digits mean, for that matter -- I don't think grep can do what you want all by itself. There's several things with : in it that could match anyway, so that probably won't narrow it down to what you want. I'll work on this a bit...
---------- Post updated at 12:38 PM ---------- Previous update was at 12:25 PM ----------
Here's how you'd match exactly the hours you want.
You could tack another grep to match a specific hostname or what have you. It's not too sophisticated. You can't take it too much farther because grep can't understand what the dates actually mean.
This is about as complex as I'd bother making it in a shell script, since shell in general has a hard time processing date information. If you want something smart enough to just specify a beginning time and date and end time and date, I'd just use perl and process the dates wholesale to compare them.
I'm writting a script to calculate the total files and number of files that have been generated but not able to access the value of qwk variable in Shell. Please suggest..
Script ::
cd /home/singhraa/tmp/scripts
count=0
total=`wc -l hk_jobs.txt` #total number of files
echo $total ... (3 Replies)
I am a newbie to awk and c programming, however am not a unix newbie. However, I do need help with a kshell script I am writing. It is almost complete, the last step is killing me. Any help would be greatly appreciated. What I am trying to do is cat a text file that has usernames. Then, using... (2 Replies)
Hello,
I have a file with 4 columns.
An arbitrary example is shown below:
a Tp 10 xyz
b Tq 8 abc
c Tp 99 pqr
d Tp 44 rst
e Tr 98 efg
Based on the values in col 2 and col 3, I will execute another program.
I have been running this:... (5 Replies)
Hi
i have a shell script which needs a string as an input parameter. How to pass the string param as an input?
In command line am running the script.
for e.g.,
a="who is a buddy?"
sh sample.sh $a
Inside the script i get this input param as $1 but only the value "who" is accepted... (12 Replies)
Hi,
I would like to compare 2 files using awk, which I can do by using:
awk 'NR==FNR{a;next} (NR > 32 && $2 in a) {print $0}' File1 and File2.
If the name of the File1 is in another file (for example, column 4 in File 3) then how can I pass this column 4 to the awk command.
Thanks in... (1 Reply)
Hi.
I need to parse file and assign some values to variables, right now i do like below
MYHOMEDIR=`awk '/Home/ {print $NF}' output.txt`
MYSHELL=`awk '/Shell/ {print $NF}' output.txt`
PRGRP=`awk '/Primary/ {print $NF}' output.txt`
SECGRP=`awk '/Second/ {print $NF}' output.txt`
In this... (10 Replies)
I have a shell program that calls another shell program
the following code works
. chkTimeFormat.sh "10/9/12 17:51:19:783."|read c
but when I am passing the the time in a variable like in the code below, the shell chkTimeFormat.sh is not returning proper value
time="10/9/12... (9 Replies)
Hi All,
Iam trying to pass global shell variables and is not working
Main script is like below
CYEAR=`date +"%y"`
CFYEAR=`date +"%Y"`
CMONTH=`date +"%m"`
if
then
PMONTH=12
PYEAR=`expr $CYEAR - 1`
PFYEAR=`expr $CFYEAR - 1`
else
PMONTH=`expr... (6 Replies)
Hello All,
May i please why my shell variable is not getting passed into awk script.
#!/bin/bash -vx
i="1EB07C50"
/bin/awk -v ID="$i" '/ID/ {match($0,/ID/);print substr($0,RSTART,RLENGTH)}' /var/log/ScriptLogs/keys.13556.txt
Thank you. (1 Reply)