Sponsored Content
Full Discussion: Exit to while read
Top Forums Shell Programming and Scripting Exit to while read Post 303007100 by Scott on Saturday 11th of November 2017 11:46:14 AM
Old 11-11-2017
Well, if you want to monitor the log, it doesn't make much sense to exit (or break) at all.

Code:
tail -fn0 test.log | while read line; do
if [[ "$line" =~ "Pattern1" ]]; then
  # do something here
  echo $line >> test2.log
elif [ "$line" =~ "Pattern2" ]; then
  # do something else here
  echo $line >> test2.log
  fi
done

(ideally this is something you would likely run nohup in the background)
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Where can I find a list of exit codes? (Exit code 64)

I'm receiving an exit code 64 in our batch scheduler (BMC product control-m) executing a PERL script on UX-HP. Can you tell me where I can find a list of exit codes and their meaning. I'm assuming the exit code is from the Unix operating system not PERL. (3 Replies)
Discussion started by: jkuchar747
3 Replies

2. Programming

exit(0) versus exit(1)

What is the difference between using exit(0) and exit(1) to exit a program? Which should I use? (9 Replies)
Discussion started by: enuenu
9 Replies

3. UNIX for Dummies Questions & Answers

what is meaning of exit(0) and exit(1)

can u tell me what is the meaning of exit(0),exit(1),exit(2) what is diff amonng these. Amit (1 Reply)
Discussion started by: amitpansuria
1 Replies

4. Shell Programming and Scripting

urgent -read exit status

i have written a shell script that invokes main class of a java prg. the java prg does a System.exit(0) or (1) based on condition. how can i read or check the status in unix.... (4 Replies)
Discussion started by: iamcool
4 Replies

5. UNIX for Dummies Questions & Answers

When reading a csv file, counter to read 20 lines and wait for minute then read next 20 till end

Hello All, i am a newbie and need some help when reading a csv file in a bourne shell script. I want to read 10 lines, then wait for a minute and then do a reading of another 10 lines and so on in the same way. I want to do this till the end of file. Any inputs are appreciated ... (3 Replies)
Discussion started by: victor.s
3 Replies

6. UNIX for Advanced & Expert Users

Returning exit code from a while read $inputline

Hi searched hi and wide for this with no luck. Maintaining a bash script that #!/usr/bin/bash #does some stuff like setting env etc. f_do_dbwork ... .. #Now I want to exit with the value of $err however $err is re-initialised to 0 on exiting the function Always 0 .... ... (3 Replies)
Discussion started by: StevePr
3 Replies

7. UNIX for Advanced & Expert Users

Timing READ command - any key to exit

Hello everyone, I would like some help on an issue I have related to the read command with ksh93 (Unix AIX). I want to implement a 'press any key to exit' scenario. I have the following code: STTY=$(stty -g) if ;then stty -echo -icanon time 0 min 0 fi k="" while ];do read k #... (5 Replies)
Discussion started by: gio001
5 Replies

8. Shell Programming and Scripting

Need the difference between exit 1 & exit 7

Hi In one of the script I am seeing some thing like exit 7,exit 1,exit 2,exit 3,exit 9,exit6.What is the difference between all of this exit.Can anyone help here please (3 Replies)
Discussion started by: ginrkf
3 Replies

9. Shell Programming and Scripting

Read exit value from Shell script

Hi all, I have a situation to read exit value of a command (not exit code) and process further. bash-4.2$ returnvalue=`ssh DOMAIN\\\\user1@10.7.7.68 'cmd /c "del C:\Users\user1\db_test.bak"'` Could Not Find C:\Users\user1\db_test.bak bash-4.2$ echo $? 0 bash-4.2$ echo $returnvalue... (3 Replies)
Discussion started by: baluchen
3 Replies

10. UNIX for Beginners Questions & Answers

UNIX Pipe -Exit when there are no bytes to read

Hi All, I'm creating a program which reads millions of bytes from the PIPE and do some processing. As the data is more, the idea is to read the pipe parallely. Sun Solaris 8 See the code below: #!/bin/sh MAXTHREAD=30 awk '{print $1}' metadata.csv > nvpipe & while do ... (3 Replies)
Discussion started by: mr_manii
3 Replies
rancid_par(1)						      General Commands Manual						     rancid_par(1)

NAME
rancid_par - parallel command processing SYNOPSIS
rancid_par [-dfiqx] [-c command] [-l logfile] [-n #] file [file...] DESCRIPTION
rancid_par takes a list of files to run a command on. The first line of each file begins with a colon (:) or a pound-sign (#). If a colon, the remainder of the line is a command to run for each of the subsequent lines. If a pound-sign, then each subsequent line is a (self-contained) command, unless the -c option was specified, in which case it operates as if the argument to -c had followed a colon on the first line. In each of the cases where the lines of the file following the first are not commands (i.e.: colon or -c), instances of open-close braces ({}) in the command will be replaced by these values. For example, a inputfile whose contents is: : echo {} a b c run with rancid_par like so: %rancid_par -q inputfile will produce the following output (order will vary): b a c The command-line options are as follows: -c Command to be run on each of the arguments following the command-line options, where the first line of the input file(s) begins with a pound-sign (#). -d Print debugging information on standard error (stderr). -f No file or STDIN, just run a quantity of the command specified with -c. -i Run commands interactively through (multiple) xterm(1) processes. -l Prefix of logfile name, as in prefix.N where N is the rancid_par process number ([0..]). Default: par.log.<time>.[0..] -n Number of simultaneous processes. Default: 3 -q Quiet mode. Do not log anything. -q is mutually exclusive with the -x and -l options and the option appearing last will take precedence. -x View rancid_par logs in real-time via an xterm(1). FILES
par.log.T.N Log file; where T is the current time in seconds since the epoch and N is the rancid_par process number ([0..]). 18 December 2007 rancid_par(1)
All times are GMT -4. The time now is 04:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy