Sponsored Content
Top Forums Shell Programming and Scripting Need help on how to append on the filename when condition met. Post 302970951 by RudiC on Thursday 14th of April 2016 02:47:10 AM
Old 04-14-2016
Not clear. WHAT does not work? What is the action to be done if the condition is met/not met?

Aside: If using awk to extract the third field (btw, above extracts ALL third fields into the variable), why not do the entire thing in awk?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Send email to user when condition met

Hi all, I plan to write a shell script to inform users on their task when certain condition met. example: If a then email user on action a else email user on action b. I'm pretty new in scripting, appreciate any suggestions. Thanks. (4 Replies)
Discussion started by: *Jess*
4 Replies

2. Shell Programming and Scripting

How to break a loop if condition is met

I am having trouble figuring this code I want to grep a text from a file and if it match certain text it break out of the loop or it should continue searching for the text Here is what I have written but it isn't working while true f=`grep 'END OF STATUS REPORT' filename` do if ... (9 Replies)
Discussion started by: Issemael
9 Replies

3. Shell Programming and Scripting

do nothing if condition is not met but not exit

Hello all, I created the below script....and it seemed to be working fine. My problem is i want the script to ignore rest of the things if my condition is not met but do not exit.... #!/bin/ksh ########################### ########################### # Set name of the listener, this... (2 Replies)
Discussion started by: abdul.irfan2
2 Replies

4. UNIX for Advanced & Expert Users

While loop only if a condition is met

All, I wrote the following section of code (which logically in PHP would of worked): tmpPATH=${1} tmpTAG=${2} if then while read tmpTAG tmpPATH do fi echo $tmpTAG echo $tmpPATH if then done < ./config.cfg fi (4 Replies)
Discussion started by: Cranie
4 Replies

5. Shell Programming and Scripting

Delete if condition met in a column

i have a table like this: id, senderNumber, blacklist ----------------------------- 1 0835636326 Y 2 0373562343 Y 3 0273646833 Y and I want to delete automatically if a new inserted row on another table consist anything on senderNumber column above using a BASH Script I... (9 Replies)
Discussion started by: jazzyzha
9 Replies

6. Shell Programming and Scripting

Awk. Abort script if condition was met.

I want to abort script if input variable matched first field in any line of a file. #!/bin/sh read INPUTVAR1 awk "{if(\$INPUTVAR1 == $1) x = 1} END {if(x==1) print \"I want to abort script here\"; else print \"OK\"}" /etc/some.conf I tried "exit" and system("exit") but no luck. (1 Reply)
Discussion started by: urello
1 Replies

7. Shell Programming and Scripting

Print specific field when condition met

Hi All, Seeking for your assistance to print all the specific field when the condition met. Ex: file1.txt 1|203|3|31243|5341|6452|623|22|00|01 3|45345|123214|6534|3423|6565|643|343|232|10 if field 1 = 1 and field 3 = 3 and field 5 = 5341 and field 6 = 6452 it will print from $1 to $10.... (2 Replies)
Discussion started by: znesotomayor
2 Replies

8. Shell Programming and Scripting

Getting the records once condition met

Hi All, Seeking for your assistance to get the records once the $2 met the condition. Ex. file 1.txt 123455,10-Aug-2020 07:33:37 AM,2335235,1323534,12343 123232,11-Aug-2015 08:33:37 PM,4234324,1321432,34364 Output: 123455,10-Aug-2020 07:33:37 AM,2335235,1323534,12343 What i did... (5 Replies)
Discussion started by: znesotomayor
5 Replies

9. Shell Programming and Scripting

Add another condition to bash for when not met

In the below I can not seem to add a line that will add Not low if the statement in bold is not true or meet. I guess when the first if statement is true/meet then print low, otherwise print Not low in $(NF + 1). I am not sure how to correctly add this. Thank you :). if(low <= $2 && $2 <=... (5 Replies)
Discussion started by: cmccabe
5 Replies

10. UNIX for Beginners Questions & Answers

awk - print when condition is met

I have a file.txt containing the following: Query= HWI-ST863:386:C5Y8UACXX:3:2302:16454:89688 1:N:0:ACACGAAT Length=100 Score E Sequences producing significant alignments: (Bits) Value ... (2 Replies)
Discussion started by: tons92
2 Replies
Log::Handler::Config(3pm)				User Contributed Perl Documentation				 Log::Handler::Config(3pm)

NAME
Log::Handler::Config - The main config loader. SYNOPSIS
use Log::Handler; my $log = Log::Handler->new(); # Config::General $log->config(config => 'file.conf'); # Config::Properties $log->config(config => 'file.props'); # YAML $log->config(config => 'file.yaml'); Or use Log::Handler; my $log = Log::Handler->new(); $log->config( config => 'file.conf' plugin => 'YAML', ); DESCRIPTION
This module makes it possible to load the configuration from a file. The configuration type is determined by the file extension. It's also possible to mix file extensions with another configuration types. PLUGINS
Plugin name File extensions ------------------------------------------ Config::General cfg, conf Config::Properties props, jcfg, jconf YAML yml, yaml If the extension is not defined then "Config::General" is used by default. METHODS
config() With this method it's possible to load the configuration for your outputs. The following options are valid: config With this option you can pass a file name or the configuration as a hash reference. $log->config(config => 'file.conf'); # or $log->config(config => \%config); plugin With this option it's possible to say which plugin you want to use. Maybe you want to use the file extension "conf" with "YAML", which is reserved for the plugin "Config::General". Examples: # this would use Config::General $log->config( config => 'file.conf' ); # this would force .conf with YAML $log->config( config => 'file.conf', plugin => 'YAML' ); section If you want to write the configuration into a global configuration file then you can create a own section for the logger: <logger> <file> filename = file.log minlevel = emerg maxlevel = warning </file> <screen> minlevel = emerg maxlevel = debug </screen> </logger> <another_script_config> foo = bar bar = baz baz = foo </another_script_config> Now your configuration is placed in the "logger" section. You can load this section with $log->config( config => 'file.conf', section => 'logger', ); # or if you load the configuration yourself to %config $log->config( config => \%config, section => 'logger', ); # or just $log->config( config => $config{logger} ); PLUGINS
Config::General - inspired by the well known apache config format Config::Properties - Java-style property files YAML - optimized for human readability EXAMPLES
Config structures A very simple configuration looks like: $log->config(config => { file => { alias => 'file1', filename => 'file1.log', maxlevel => 'info', minlevel => 'warn', }, screen => { alias => 'screen1', maxlevel => 'debug', minlevel => 'emerg', } }); Now, if you want to add another file-output then you can pass the outputs with a array reference: $log->config(config => { file => [ { alias => 'file1, filename => 'file1.log', maxlevel => 'info', minlevel => 'warn', }, { alias => 'file2', filename => 'file2.log', maxlevel => 'error', minlevel => 'emergency', } ], screen => { alias => 'screen1', maxlevel => 'debug', minlevel => 'emerg', }, }); It's also possible to pass the outputs as a hash reference. The hash keys "file1" and "file2" will be used as aliases. $log->config(config => { file => { file1 => { filename => 'file1.log', maxlevel => 'info', minlevel => 'warn', }, file2 => { filename => 'file2.log', maxlevel => 'error', minlevel => 'emergency', } }, screen => { alias => 'screen1', maxlevel => 'debug', minlevel => 'emerg', }, }); If you pass the configuration with the alias as a hash key then it's also possible to pass a section called "default". The options from this section will be used as defaults. $log->config(config => { file => { default => { # defaults for all file-outputs mode => 'append', }, file1 => { filename => 'file1.log', maxlevel => 'info', minlevel => 'warn', }, file2 => { filename => 'file2.log', maxlevel => 'error', minlevel => 'emergency', } }, screen => { alias => 'screen1', maxlevel => 'debug', minlevel => 'emerg', }, }); Examples for the config plugins Config::General <file> alias = file1 fileopen = 1 reopen = 1 permissions = 0640 maxlevel = info minlevel = warn mode = append timeformat = %b %d %H:%M:%S debug_mode = 2 filename = example.log message_layout = '%T %H[%P] [%L] %S: %m' </file> Or <file> <file1> fileopen = 1 reopen = 1 permissions = 0640 maxlevel = info minlevel = warn mode = append timeformat = %b %d %H:%M:%S debug_mode = 2 filename = example.log message_layout = '%T %H[%P] [%L] %S: %m' </file1> </file> YAML --- file: alias: file1 debug_mode: 2 filename: example.log fileopen: 1 maxlevel: info minlevel: warn mode: append permissions: 0640 message_layout: '%T %H[%P] [%L] %S: %m' reopen: 1 timeformat: '%b %d %H:%M:%S' Or --- file: file1: debug_mode: 2 filename: example.log fileopen: 1 maxlevel: info minlevel: warn mode: append permissions: 0640 message_layout: '%T %H[%P] [%L] %S: %m' reopen: 1 timeformat: '%b %d %H:%M:%S' Config::Properties file.alias = file1 file.reopen = 1 file.fileopen = 1 file.maxlevel = info file.minlevel = warn file.permissions = 0640 file.mode = append file.timeformat = %b %d %H:%M:%S file.debug_mode = 2 file.filename = example.log file.message_layout = '%T %H[%P] [%L] %S: %m' Or file.file1.alias = file1 file.file1.reopen = 1 file.file1.fileopen = 1 file.file1.maxlevel = info file.file1.minlevel = warn file.file1.permissions = 0640 file.file1.mode = append file.file1.timeformat = %b %d %H:%M:%S file.file1.debug_mode = 2 file.file1.filename = example.log file.file1.message_layout = '%T %H[%P] [%L] %S: %m' PREREQUISITES
Carp Params::Validate EXPORTS
No exports. REPORT BUGS
Please report all bugs to <jschulz.cpan(at)bloonix.de>. If you send me a mail then add Log::Handler into the subject. AUTHOR
Jonny Schulz <jschulz.cpan(at)bloonix.de>. COPYRIGHT
Copyright (C) 2007-2009 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-11-21 Log::Handler::Config(3pm)
All times are GMT -4. The time now is 07:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy