Sponsored Content
Top Forums Shell Programming and Scripting Reduce the number of lines in script Post 302851341 by Vikram_Tanwar12 on Sunday 8th of September 2013 08:32:14 AM
Old 09-08-2013
Reduce the number of lines in script

Hello All,

I have created a script which will show the errors from a log file in between a particular section.

Code:
v1=$(sed -n "/Main Report/,/Main Report End/p" input | grep -i 'Unable to find'
v2=$(sed -n "/Main Report/,/Main Report End/p" input | grep -i 'Unable to add'

if [ -z "$v1" ]
then
echo "All report deployed properly"
else
echo "List of report failed to deploy in Main Report due to Null pointer exception"
echo "$v1"
fi 

if [ -z "v2"]
then
echo "All Report Deployed Properly"
else
echo "List of report failed to deploy in Main Report due to xml issue"
echo "$v"
fi 

v3=$(sed -n "/Second Report/,/Second Report End/p" input | grep -i 'Unable to find'
v4=$(sed -n "/Second Report/,/Second Report End/p" input | grep -i 'Unable to add'

if [ -z "$v3" ]
then
echo "All report deployed properly"
else
echo "List of report failed to deploy in Second Report due to Null pointer exception"
echo "$v3"
fi 

if [ -z "v4"]
then
echo "All Report Deployed Properly"
else
echo "List of report failed to deploy in Second Report due to xml issue"
echo "$v4"
fi

Is there a way I can use some loop to reduce these code lines. The error are same but in different part of logs.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

need inputs on how i can change my script to reduce amount of time the script takes

HI , I have a list1 which consists of data that i have to search and a list2 which has the files that need to be searched .So basically i am using list1 on list2 to see if list1 data is present if found replace it .I have written the code using foreach loop for each list .This is taking the... (1 Reply)
Discussion started by: madhul2002
1 Replies

2. UNIX for Dummies Questions & Answers

How to reduce multiple files into a specific number of files

Can anyone please let me know how do I reduce files into a specific number of files by cat'ing files? For example: 15 files must be reduced to 1 or 5 or 9 (possible values 1 to 14) (5 Replies)
Discussion started by: aryanbelank
5 Replies

3. Shell Programming and Scripting

Script to split files based on number of lines

I am getting a few gzip files into a folder by doing ftp to another server. Once I get them I move them to another location .But before that I need to make sure each gzip is not more than 5000 lines and split it up . The files I get are anywhere from 500 lines to 10000 lines in them and is in gzip... (4 Replies)
Discussion started by: gubbu
4 Replies

4. Shell Programming and Scripting

perl script on how to count the total number of lines of all the files under a directory

how to count the total number of lines of all the files under a directory using perl script.. I mean if I have 10 files under a directory then I want to count the total number of lines of all the 10 files contain. Please help me in writing a perl script on this. (5 Replies)
Discussion started by: adityam
5 Replies

5. Shell Programming and Scripting

To reduce the bash script length!!!

Hi friends, at last i finish my script to find the status of the URL , in this code i used all the status codes, because of this it take too much of length. with the help of wiki only i find all the status codes. Status codes in HTTP #!/bin/bash timevar=`date +%d-%m-%Y_%H.%M.%S` #--... (6 Replies)
Discussion started by: anishkumarv
6 Replies

6. UNIX and Linux Applications

Looking to reduce the number a cpus available for SGE

Hey all Im looking to reduce the number of cpus available on a certain node in our cluster available for jobs using SGE. i.e. we have one node that has 24 cpus available for jobs on SGE, i would like to reduce that to 16. Thanks (1 Reply)
Discussion started by: olifu02
1 Replies

7. UNIX for Dummies Questions & Answers

Writing a script to print the number of lines in multiple files

Hi I have 1000 files labelled data1.txt through data1000.txt. I want to write a script that prints out the number of lines in each txt file and outputs it in the following format: Column 1: number of data file (1 through 1000) Column 2: number of lines in the text file Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies

8. Shell Programming and Scripting

[Solved] Script to concatenate 2 files with the same number of lines

Hi everyone, I have two files, namely: file1: file1Col1Row1;file1Col2Row1;file1Col3Row1 file1Col1Row2;file1Col2Row2;file1Col3Row2 file1Col1Row3;file1Col2Row3;file1Col3Row3file2: file2Col1Row1;file2Col2Row1;file2Col3Row1 file2Col1Row2;file2Col2Row2;file2Col3Row2... (0 Replies)
Discussion started by: gacanepa
0 Replies

9. Shell Programming and Scripting

Reduce the number of lines by using Array

I have the following code to count the number of how many times the name occurred in one file. The code is working fine and the output is exactly what I want. The problem is the real code has more than 50 names in function listname which cause function name to have more than 50 case ,and function... (14 Replies)
Discussion started by: samsan
14 Replies

10. UNIX for Beginners Questions & Answers

Print number of lines for files in directory, also print number of unique lines

I have a directory of files, I can show the number of lines in each file and order them from lowest to highest with: wc -l *|sort 15263 Image.txt 16401 reference.txt 40459 richtexteditor.txt How can I also print the number of unique lines in each file? 15263 1401 Image.txt 16401... (15 Replies)
Discussion started by: spacegoose
15 Replies
SCRIPTMGR(1)															      SCRIPTMGR(1)

NAME
scriptmgr - utility for controlling other skytools scripts. SYNOPSIS
scriptmgr.py [switches] config.ini <command> [-a | job_name ... ] DESCRIPTION
scriptmgr is used to manage several scripts together. It discovers potential jobs based on config file glob expression. From config file it gets both job_name and service type (that is the main section name eg [cube_dispatcher]). For each service type there is subsection in the config how to handle it. Unknown services are ignored. COMMANDS
status scriptmgr config.ini status Show status for all known jobs. start scriptmgr config.ini start -a scriptmgr config.ini start job_name1 job_name2 ... launch script(s) that are not running. stop scriptmgr config.ini stop -a scriptmgr config.ini stop job_name1 job_name2 ... stop script(s) that are running. restart scriptmgr config.ini restart -a scriptmgr config.ini restart job_name1 job_name2 ... restart scripts. reload scriptmgr config.ini reload -a scriptmgr config.ini reload job_name1 job_name2 ... Send SIGHUP to scripts that are running. CONFIG
Common configuration parameters job_name Name for particulat job the script does. Script will log under this name to logdb/logserver. The name is also used as default for PgQ consumer name. It should be unique. pidfile Location for pid file. If not given, script is disallowed to daemonize. logfile Location for log file. loop_delay If continuisly running process, how long to sleep after each work loop, in seconds. Default: 1. connection_lifetime Close and reconnect older database connections. log_count Number of log files to keep. Default: 3 log_size Max size for one log file. File is rotated if max size is reached. Default: 10485760 (10M) use_skylog If set, search for [./skylog.ini, ~/.skylog.ini, /etc/skylog.ini]. If found then the file is used as config file for Pythons logging module. It allows setting up fully customizable logging setup. scriptmgr parameters config_list List of glob patters for finding config files. Example: config_list = ~/dbscripts/conf/*.ini, ~/random/conf/*.ini Service section parameters cwd Working directory for script. args Arguments to give to script, in addition to -d. script Path to script. Unless script is in PATH, full path should be given. disabled If this service should be ignored. Example config file [scriptmgr] job_name = scriptmgr_livesrv logfile = ~/log/%(job_name)s.log pidfile = ~/pid/%(job_name)s.pid config_list = ~/scripts/conf/*.ini # defaults for all service sections [DEFAULT] cwd = ~/scripts [table_dispatcher] script = table_dispatcher.py args = -v [cube_dispatcher] script = python2.4 cube_dispatcher.py disabled = 1 [pgqadm] script = ~/scripts/pgqadm.py args = ticker COMMAND LINE SWITCHES
Following switches are common to all skytools.DBScript-based Python programs. -h, --help show help message and exit -q, --quiet make program silent -v, --verbose make program more verbose -d, --daemon make program go background Following switches are used to control already running process. The pidfile is read from config then signal is sent to process id specified there. -r, --reload reload config (send SIGHUP) -s, --stop stop program safely (send SIGINT) -k, --kill kill program immidiately (send SIGTERM) Options specific to scriptmgr: -a, --all Operate on all non-disabled scripts. 03/13/2012 SCRIPTMGR(1)
All times are GMT -4. The time now is 05:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy