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
HWLOC-BIND(1)							       hwloc							     HWLOC-BIND(1)

NAME
hwloc-bind - Launch a command that is bound to specific processors and/or memory. SYNOPSIS
hwloc-bind [options] <location1> [<location2> [...] ] [--] <command> ... OPTIONS
See below for a description of valid <location> formats. --cpubind Use following arguments for CPU binding (default). --membind Use following arguments for memory binding. If --mempolicy is not also given, the default policy is bind. --mempolicy <policy> Change the memory binding policy. The available policies are default, firsttouch, bind, interleave replicate and nexttouch. This option is only meaningful when an actual binding is also given with --membind. If --membind is given without --mempolicy, the default policy is bind. --get Report the current bindings. When combined with --membind, report the memory binding instead of CPU binding. --get-last-cpu-location Report the last processors where the process ran. Note that the result may already be outdated when reported since the operating system may move the process to other processors at any time according to the binding. This option cannot be combined with --mem- bind. --single Bind on a single CPU to prevent migration. --strict Require strict binding. --get Retrieve the current process binding --pid <pid> Operate on pid <pid> -p --physical take OS/physical indexes instead of logical indexes -l --logical take logical indexes instead of physical/OS indexes (default) --taskset Display CPU set strings in the format recognized by the taskset command-line program instead of hwloc-specific CPU set string format. This option has no impact on the format of input CPU set strings, both formats are always accepted. -v Verbose output. --version Report version and exit. DESCRIPTION
hwloc-bind execs an executable (with optional command line arguments) that is bound to the specified location (or list of locations). Upon successful execution, hwloc-bind simply sets bindings and then execs the executable over itself. NOTE: It is highly recommended that you read the hwloc(7) overview page before reading this man page. Most of the concepts described in hwloc(7) directly apply to the hwloc-bind utility. EXAMPLES
hwloc-bind's operation is best described through several examples. More details about how locations are specified on the hwloc-bind com- mand line are described in hwloc(7). To run the echo command on the first logical processor of the second socket: hwloc-bind socket:1.pu:0 -- echo hello which is exactly equivalent to hwloc-bind socket:1.pu:0 echo hello To bind the "echo" command to the first core of the second socket and the second core of the first socket: hwloc-bind socket:1.core:0 socket:0.core:1 echo hello Note that binding the "echo" command to multiple processors is probably meaningless (because "echo" is likely implemented as a single- threaded application); these examples just serve to show what hwloc-bind can do. To run on the first three sockets on the second and third nodes: hwloc-bind node:1-2.socket:0:3 echo hello which is also equivalent to: hwloc-bind node:1-2.socket:0-2 echo hello Note that if you attempt to bind to objects that do not exist, hwloc-bind will not warn unless -v was specified. To run on processor with physical index 2 in socket with physical index 1: hwloc-bind --physical socket:1.core:2 echo hello To run on odd cores within even sockets: hwloc-bind socket:even.core:odd echo hello To run on the first socket, except on its second and fifth cores: hwloc-bind socket:0 ~socket:0.core:1 ~socket:0.core:4 echo hello To run anywhere except on the first socket: hwloc-bind all ~socket:0 echo hello To run on a core near the network interface named eth0: hwloc-bind os=eth0 echo hello To run on a core near the PCI device whose bus ID is 0000:01:02.0: hwloc-bind pci=0000:01:02.0 echo hello To bind memory on second memory node and run on first node (when supported by the OS): hwloc-bind --cpubind node:1 --membind node:0 echo hello The --get option can report current bindings. This example shows nesting hwloc-bind invocations to set a binding and then report it: hwloc-bind node:1.socket:2 hwloc-bind --get On one of the hwloc developer's machines, this example reports "0x00004444,0x44000000". The mask reported on your machine may be differ- ent. Locations may also be specified as a hex bit mask (typically generated by hwloc-calc). For example: hwloc-bind 0x00004444,0x44000000 echo hello hwloc-bind `hwloc-calc node:1.socket:2` echo hello Memory binding may also be reported: hwloc-bind --membind node:1 --mempolicy interleave -- hwloc-bind --get --membind This returns a string describing the memory binding, such as "0x000000f0 (interleave)". Note that if the system does not contain any NUMA nodes, the reported string will indicate that the process is bound to the entire system memory (e.g., "0xf...f"). RETURN VALUE
Upon successful execution, hwloc-bind execs the command over itself. The return value is therefore whatever the return value of the com- mand is. hwloc-bind will return nonzero if any kind of error occurs, such as (but not limited to): failure to parse the command line, failure to retrieve process bindings, or lack of a command to execute. SEE ALSO
hwloc(7), lstopo(1), hwloc-calc(1), hwloc-distrib(1) 1.4.1 Feb 27, 2012 HWLOC-BIND(1)
All times are GMT -4. The time now is 06:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy