LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 08: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, 09:17 AM   #2
Madhu Desai
Member
 
Registered: Mar 2013
Distribution: Rocky, Fedora, Ubuntu
Posts: 541

Rep: Reputation: 153Reputation: 153
Code:
$ grep 'PASSED\|Time' /usr/lib/edge/lists/simple_job/edge_summary.txt
 
1 members found this post helpful.
Old 12-11-2013, 01: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, 01:46 PM   #4
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
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 02:16 PM.
 
1 members found this post helpful.
Old 12-11-2013, 02:52 PM   #5
Madhu Desai
Member
 
Registered: Mar 2013
Distribution: Rocky, Fedora, Ubuntu
Posts: 541

Rep: Reputation: 153Reputation: 153
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, 02: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, 02:57 PM   #7
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
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 03:02 PM.
 
1 members found this post helpful.
Old 12-11-2013, 03: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-11-2013, 11:15 PM   #9
Madhu Desai
Member
 
Registered: Mar 2013
Distribution: Rocky, Fedora, Ubuntu
Posts: 541

Rep: Reputation: 153Reputation: 153
You're welcome

Also, 2nd part of path is not required.

Last edited by Madhu Desai; 12-11-2013 at 11:25 PM.
 
1 members found this post helpful.
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:40 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
Open Source Consulting | Domain Registration