LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-29-2013, 01:46 AM   #1
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Rep: Reputation: Disabled
Need to match if the system time is available in file or not


Hi,

I have a file1 which contains:
FPS-SCHED|00:30|01:30|02:30|03:30|04:30|05:30|06:30|07:30|08:30|09:30|10:30|11:30|12:30|13:30|14:30|15:3 0|16:30|17:30|18:30|19:30|20:30|21:30|22:30|23:30|
PODUKC-SCHED|09:10|10:10|11:10|12:10|13:10|14:10|15:10|16:10|17:10|18:10|19:10|20:10|


now script runs @ every 2 min and i need to check for FPS-SCHED if the current system time is available in the file1 or not, if it is available then will do further checks and similar for PODUKC-SCHED and other lines in a file1. How do i check if the current system time is available in the file1 for FPS-SCHED?
lets say for FPS-SCHED if script runs @ 00:34 however this time is not available in file1 for FPS-SCHED. then
How do i come to know if the current system time is available in the file1 for FPS-SCHED or not ?

Last edited by santosh0782; 11-29-2013 at 01:48 AM.
 
Old 11-29-2013, 02:21 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Is this what you want:
Code:
#!/bin/bash

currTime=$(date '+%H:%M')

if grep "FPS-SCHED" file1 | grep "$currTime" 1>/dev/null
then
  echo "Present"
else
  echo "Not present"
fi
 
1 members found this post helpful.
Old 11-30-2013, 05:27 AM   #3
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
Smile

Hi,

yes..was expecting the same.. Thanks a lot :-)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] AWK: match multiple strings in the file, print 1 when match and 0 when not cristalp Programming 12 11-15-2011 11:18 AM
check file system every time.... keimasi Linux - Desktop 7 03-17-2011 12:29 PM
Is there any way to prevent sed from updating file modified time when no match? DennyCrane Linux - General 2 05-01-2009 08:28 AM
File System Creation Time meshcurrent Linux - General 5 02-08-2009 12:46 PM
system file changes to read only by it self after some time.... ghost333 Slackware 3 12-02-2008 11:05 AM


All times are GMT -5. The time now is 07:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration