Sponsored Content
The Lounge War Stories Interesting script issue clubbed with crontab. Post 303006555 by bakunin on Friday 3rd of November 2017 10:57:04 AM
Old 11-03-2017
Quote:
Originally Posted by RavinderSingh13
find -type f -exec grep -l "old_user" {} \+
A trick i have learned here (and i am ashamed i can't remember from who) is to always add a second file to grep when using it this way.

grep, when called with a single file, will not show the file name where it found something:

Code:
find /some/where -type f -exec grep "bla foo" {} \;
whatever bla foo something
another hit bla foo
....

But write it like this:
Code:
find /some/where -type f -exec grep "bla foo" /dev/null {} \;

and grep will add the file names of the files at the beginning of the line.

bakunin
This User Gave Thanks to bakunin For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Crontab Issue

I have a backup script that is suppose to run every night of the week, but it never does, it starts to run. The way I can tell is that the dates on dump_log are changing to when the script runs. If I look in the cron log file is shows ! > root 506342 cr /etc/back_up Fri Aug 5 10:30:00... (2 Replies)
Discussion started by: rickyt00
2 Replies

2. Shell Programming and Scripting

Facing issue in Solaris OS in crontab for running shell script

Hello i have a shell script. it is running fine when i manually run at command prompt using following command ./script_file but while running shell script from crontab, it is giving error in each line. (2 Replies)
Discussion started by: mabrar
2 Replies

3. Shell Programming and Scripting

Report filtering - Weird issue and interesting - UrgentPlease

Hi, Could any one help me to extract data from a report. I would like to get the two lines which are just below the separations I have a report like this -------------------------------------------------------------------------- Pid Command Inuse Pin Pgsp Virtual... (2 Replies)
Discussion started by: ajilesh
2 Replies

4. UNIX for Advanced & Expert Users

crontab issue

I am adding a piece of code which adds entry in crontab ((in brown color)) \crontab -l > $tmpfile echo "Removing the cleanProcess entry if it already existed.." grep -v "cleanProcess.sh" $tmpfile > $newtmpfile lcnt=`grep -c "cleanProcess.sh" $tmpfile` echo... (4 Replies)
Discussion started by: crackthehit007
4 Replies

5. Programming

Interesting issue with pthread_mutex_lock and siglongjmp in AIX 5.3 (and no other OS)

Executive summary: Code (posted below) cores in AIX 5.3, despite being compiled and run successfully on several other operating systems. Code is attempting to verify that pthread_mutex_lock can be successfully aborted by siglongjmp. I do not believe this is an unreasonable requirement. If... (1 Reply)
Discussion started by: DreamWarrior
1 Replies

6. Shell Programming and Scripting

issue with running script with crontab

I am facing a strange issue while running a script(eg A) from the crontab entry the script calls one more script(eg B) within it now when i run the script A manually(with nohup) it also executes the script B (embedded inside it) as expected. but when i run the script A from the crontab entry... (7 Replies)
Discussion started by: mad_man12
7 Replies

7. Shell Programming and Scripting

crontab issue

Helo . I have 2.6.13-1.1526_FC4smp here. I am trying to make crontab execute my simple shell script, but noting happens. here is how i am testing this : $ pwd /home/oracle $ ls -l two* ls: two*: No such file or directory $ $ crontab -e crontab: installing new crontab $ $ crontab... (7 Replies)
Discussion started by: tonijel
7 Replies

8. Shell Programming and Scripting

Long and interesting but harmless Terminal script

Hi, I was mucking around with Maven for Eclipse the other day, working on an audio visual project and I was struck by how cool the terminal executing massive amounts of commands is. I have an odd request. I was wondering if people knew of a terminal script that outputed a lot of data,... (0 Replies)
Discussion started by: Red_beardo
0 Replies

9. Shell Programming and Scripting

Crontab issue

hi, i have schduled a job through crontab, but it is not getting executed. bash-3.2$ crontab -l # Monthly Download (mm hh DD MM format) 35 05 01 04 * /home/ftpsrp/srpftp1/download/ofrdb/scripts/load_ofrdb.sh crr.sh here is the permission of the .sh files -rwxr--r-- 1 ftpsrp srp ... (7 Replies)
Discussion started by: lovelysethii
7 Replies

10. Shell Programming and Scripting

Issue in running shell script in crontab

I'm having a shell script which has to be run only once at the specified time. Shell script is like following, #!/bin/bash db2 connect to XXX > connection_status.txt This script is scheduled in crontab as following, 50 4 8 5 0 sh script.sh scheduled script is run at the specified time... (1 Reply)
Discussion started by: Rajkumar Gandhi
1 Replies
ZGREP(1)						      General Commands Manual							  ZGREP(1)

NAME
zgrep - search possibly compressed files for a regular expression SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code: (-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If the GREP environment variable is set, zgrep uses it as the grep program to be invoked. EXIT CODE
2 - An option that is not supported was specified. AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1) ZGREP(1)
All times are GMT -4. The time now is 09:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy