Pausing a Grep output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pausing a Grep output
# 1  
Old 06-14-2005
Pausing a Grep output

I am writing a small script which allows users to grep multiple log files across multiple directories, and often the output produced by the grep statements is quite lengthy. It would be nice if the output to the screen could be "paused" when it reaches a certain length (say, the length of the screen), and resumed once the user hits a key. I would rather not output the results to a file, but if the screen output cannot be tamed I may have no choice.
# 2  
Old 06-14-2005
grep problem

use

grep "var" filename | less
# 3  
Old 06-14-2005
use

| more

after your 'grep' commands
# 4  
Old 06-15-2005
grep command

Use

grep command | less

as ' less ' has more capabilities than ' more ' .
# 5  
Old 06-15-2005
But less is available on fewer systems than more.

Cheers
ZB
# 6  
Old 06-15-2005
I would strongly discourage any such thing.

If the user wants to have the output paginated he can pipe itself through "pg", "more", "less" or whatever is his favourite paginating program. If the user wants to use the output in any other way (like: capture it in a file, feed it to another program in a pipe, ...) the usage of a paginating software inside the script would prevent all these possibilities.

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Oracle/SQLPlus help - ksh Script calling .sql file not 'pausing' at ACCEPT, can't figure out why

Hi, I am trying to write a script that calls an Oracle SQL file who in turns call another SQL file. This same SQL file has to be run against the same database but using different username and password at each loop. The first SQL file is basically a connection test and it is supposed to sort... (2 Replies)
Discussion started by: newbie_01
2 Replies

2. Shell Programming and Scripting

Pausing a cron job

Hi All, I have a cronjob which runs a script every 5 mins. My problem is before the script is completed the cron job starts again after 5 mins. How can I put this second cron job to wait unless the first script has completed. Could you please help me on that (7 Replies)
Discussion started by: prats_7678
7 Replies

3. UNIX for Beginners Questions & Answers

Grep output

Hi. I have a command line that will generate exif data from .jpg files... So to get the Camera Model I use: find -iname "*.jpg" -print0 | xargs -0 exiftool -a | grep "Camera Model" But I want the file name AND the camera model... How to I get the grep to give me TWO bits of information from... (2 Replies)
Discussion started by: TuftyDave
2 Replies

4. Shell Programming and Scripting

Read not prompting/ pausing for input

Heya people, So my script is one of those make-user-scripts, making a bunch of directories in the home folder and copying some files over into the new directories. However, part of the thing my script need to do is check the home folder if a username matches with a directory which already exists.... (6 Replies)
Discussion started by: Cloudy_Cat
6 Replies

5. Shell Programming and Scripting

How to grep the desired output and output to a file?

currently I have process from a raw file to this stage ALTER TABLE "EXCEL_ADMIN"."TC_TXN_VOID" ADD CONSTRAINT "PK_TC_TXN_VOID" PRIMARY KEY ("TC_TXN_IID") ALTER TABLE "EXCEL_ADMIN"."TC_TXN_AMT" ADD CONSTRAINT "PK_TC_TXN_AMT" PRIMARY KEY ("TC_TXN_AMT_IID") ALTER TABLE... (10 Replies)
Discussion started by: jediwannabe
10 Replies

6. UNIX for Dummies Questions & Answers

Pausing and resuming process on laptop

Hi, I'm wondering if it's possible to pause a process I'm running in the background, close my laptop (I need to leave the office), and continue the process (when I get home). I've been running a process for a really long time and I don't want to have to start it over. Thanks in advance! (9 Replies)
Discussion started by: ShiGua
9 Replies

7. Shell Programming and Scripting

grep output

hi i am running grep -c on a bunch of files some of which may be non existent. The output i get is in the same order as the files grep checks and this is what i want as i need to copy the output to a spreadsheet. However when i tried to pipe the output to sed to strip away the filenames and just... (5 Replies)
Discussion started by: chronics
5 Replies

8. Shell Programming and Scripting

Pausing between two executions in a shell script

HI, Please help me on this. I have to execute 100 scripts which i have redirected in to a file . I want to pause the script after first execution and once i say enter key word it has to go to next execution. My looks like for RUNFILES in `cat ${SOURCEFILES}/scripts` do echo $RUNFILES; ... (1 Reply)
Discussion started by: srichunduru
1 Replies

9. Shell Programming and Scripting

Pausing function with Perl

Hi all, I got the request to make a Perl script with the requirements as follow: 1. Make a program that just shows the time, a clock on the format 12:01:24. 2. When someone press key combination Ctrl -p the program should pause, ie the clock will stand still. When the Ctrl - p is pressed... (3 Replies)
Discussion started by: milo
3 Replies

10. Shell Programming and Scripting

pausing a script

hello all, I have a script (Solaris v8 ksh) monitoring an inbound directory for reports. The script will then capture the report based on a set of circumstances. However I am unable to capture a report larger then 2-Gig in size due to program limitations. What I need to do is pause the monitor... (6 Replies)
Discussion started by: gozer13
6 Replies
Login or Register to Ask a Question