LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 12-06-2013, 09:26 AM   #1
T-Dub116
Member
 
Registered: Aug 2013
Location: Dolyestown
Posts: 88

Rep: Reputation: Disabled
grep Word and Date from file


I run this command and It lets me know that my backups passed

# grep -R PASSED /usr/lib/edge/lists/simple_job/edge_summary.txt
Backup Type [Status] = Master [PASSED!]
Verify Type [Status] = Level-2 (Bit) [PASSED!]

I also need to know the time that this file was last updated.

# l edge_summary.txt
-rwxr-xr-x 1 root root 2911 Dec 5 18:30 edge_summary.txt

or

in the file its self it has a time and date:

Backup Time = 2013-12-05 18:30:04
Message Time = 2013-12-05 18:30:45

someway I could maybe use grep to look at this date/time too, but the l edge_summary.log may be an easier way.



.
 
Old 12-06-2013, 10:17 AM   #2
mddnix
Member
 
Registered: Mar 2013
Distribution: Redhat, Ubuntu
Posts: 516

Rep: Reputation: 139Reputation: 139
Code:
$ grep 'PASSED\|Time' /usr/lib/edge/lists/simple_job/edge_summary.txt
 
1 members found this post helpful.
Old 12-11-2013, 02:40 PM   #3
T-Dub116
Member
 
Registered: Aug 2013
Location: Dolyestown
Posts: 88

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by mddesai View Post
Code:
$ grep 'PASSED\|Time' /usr/lib/edge/lists/simple_job/edge_summary.txt

Is there a way to use grep to see the permissions on a file? for example in a certain dir I need all files to be chmod 666 or higher > -rw-rw-rw-

sometimes theses files permisson get changed, is there a way to run a grep command to look at the permissions and if it ever finds a file that is below 666 it will run chmod ugo+rw /appl/foodconnex/output/* > this way it will not effect files and folders higher then 666 but it will move ever file below 666 to 666.
 
Old 12-11-2013, 02:46 PM   #4
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,051

Rep: Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852
i think the man page for test allows you to check for permissions. you will probably need to construct a shell script to handle the rules/exceptions for your situation.

its probably just easier to change the perms to 666 no matter what they are... its like switching on a lite (theres no need to check if it is on, and then turn it on).

Last edited by schneidz; 12-11-2013 at 03:16 PM.
 
1 members found this post helpful.
Old 12-11-2013, 03:52 PM   #5
mddnix
Member
 
Registered: Mar 2013
Distribution: Redhat, Ubuntu
Posts: 516

Rep: Reputation: 139Reputation: 139
Quote:
is there a way to run a grep command to look at the permissions and if it ever finds a file that is below 666 it will run chmod ugo+rw /appl/foodconnex/output/* > this way it will not effect files and folders higher then 666 but it will move ever file below 666 to 666.
Code:
find /appl/foodconnex/output/ -type f ! -perm -666 -exec chmod 666 {} \;
 
2 members found this post helpful.
Old 12-11-2013, 03:52 PM   #6
T-Dub116
Member
 
Registered: Aug 2013
Location: Dolyestown
Posts: 88

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by schneidz View Post
i think the man page for test allows you to check for permissions. you will probably need to construct a shell script to handle the rules/exceptions for your situation.

its probably just easier to change the perms to 666 no matter what they are... its like switching on a lite (theres no need to check if it is on, and then turn it on).
In my situation, for some reason users will log into my application and if different users use different files sometimes the files permissions get changed so then the users can no longer access the file that is why I need to have something automatic...I will look into s script
 
Old 12-11-2013, 03:57 PM   #7
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,051

Rep: Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852
Quote:
Originally Posted by mddesai View Post
Code:
find /appl/foodconnex/output/ -type f ! -perm -666 -exec chmod 666 {} \;
or simply, would:
Code:
chmod 666 *.txt
do the same thing ?
edit: i'll answer my own question with what was previosly quoted- no, because:
Quote:
is there a way to run a grep command to look at the permissions and if it ever finds a file that is below 666 it will run chmod ugo+rw /appl/foodconnex/output/* > this way it will not effect files and folders higher then 666 but it will move ever file below 666 to 666.

Last edited by schneidz; 12-11-2013 at 04:02 PM.
 
1 members found this post helpful.
Old 12-11-2013, 04:26 PM   #8
T-Dub116
Member
 
Registered: Aug 2013
Location: Dolyestown
Posts: 88

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by mddesai View Post
Code:
find /appl/foodconnex/output/ -type f ! -perm -666 -exec chmod 666 {} \;

Thank you command works perfectly

find /appl/foodconnex/output/ -type f ! -perm -666 -exec chmod ugo+rw /appl/foodconnex/output/ {} \;

(I use chmod ugo+rw just to be safe so no files over 666 will be touched even though the find command does that any way)
 
Old 12-12-2013, 12:15 AM   #9
mddnix
Member
 
Registered: Mar 2013
Distribution: Redhat, Ubuntu
Posts: 516

Rep: Reputation: 139Reputation: 139
You're welcome

Also, 2nd part of path is not required.

Last edited by mddnix; 12-12-2013 at 12:25 AM.
 
1 members found this post helpful.
  


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
grep a word from a file thomas2004ch Linux - Software 11 03-28-2013 12:49 PM
[SOLVED] log file grep by date and year JJJCR Linux - General 10 01-14-2013 10:24 PM
finding a word by using grep in whole file system c2431993 Linux - Newbie 2 09-29-2010 07:38 PM
grep a word in a .tar.gz file prernabhagat Linux - General 1 12-07-2007 02:53 AM
Word count with grep DiagonalArg Linux - Software 3 02-13-2006 01:46 PM


All times are GMT -5. The time now is 11:07 PM.

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