Sponsored Content
Top Forums Shell Programming and Scripting Extract multiple values into corresponding variables Post 302995509 by kchinnam on Thursday 6th of April 2017 03:37:28 PM
Old 04-06-2017
Extract multiple values into corresponding variables

Here is my input
Code:
# MANIFEST.MF
Manifest-Version: 1.0
Build-Jdk: 1.6.0
Built-By: CM_TEAM
Build_SvnRev: 662789
Build_Number: 13.0.0.0-JDK8
Build_Date: Wed 04/05/2017-20:48:19.17
Archiver-Version: Plexus Archiver
Created-By: Apache Maven 3.1.0

Here is the expected output:
Code:
13.0.0.0-JDK8,04/05/2017-20:48:19.17,662789

Here the code I have to get above output.

Code:
out=$(cat MANIFEST.MF | tr -d '\r' | grep '^Build_'); 
BN=$(echo "$out" | grep Build_Number| awk '{print $NF}'); 
BS=$(echo "$out" | grep Build_SvnRev | awk '{print $NF}');
BD=$(echo "$out" | grep Build_Date | awk '{print $NF}');  
echo "$BN,$BD,$BS"

Is there a way that we can do this efficiently without having to repeat grep/awk multiple times? may be perl/awk can do that?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Error in fetching multiple row values into variables

Hello Team, In the below code....The variabe values are not fetch from input table into SELECT statements. =========================== #!/usr/bash DATABASE=XXXXX inputFILE=$1 db2 connect to $DATABASE TABLENAME=`echo $inputFILE|awk '{print $1}'` COLUMNNAME=`echo $inputFILE|awk... (2 Replies)
Discussion started by: rocking77
2 Replies

2. Shell Programming and Scripting

Extract multiple values from a tnsping output

Hi all, Can anyone help with the following request? I need to extract HOST value, SERVICE_NAME and msec value from a tnsping output and append to a file. The tnsping output is typically as follows: Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION = (ADDRESS =... (4 Replies)
Discussion started by: jonnyd
4 Replies

3. Shell Programming and Scripting

Running a script with multiple variables like 25 variables.

Hi All, i have a requirement where i have to run a script with at least 25 arguements and position of arguements can also change. the unapropriate way is like below. can we achieve this in more good and precise way?? #!/bin/ksh ##script is sample.ksh age=$1 gender=$2 class=$3 . . .... (3 Replies)
Discussion started by: Lakshman_Gupta
3 Replies

4. Shell Programming and Scripting

[Solved] Counting The Number of Lines Between Values with Multiple Variables

Hey everyone, I have a bunch of lines with values in field 4 that I am interested in. If these values are between 1 and 3 I want it to count all these values to all be counted together and then have the computer print out LOW and the number of lines with those values in between 1 and 3,... (2 Replies)
Discussion started by: VagabondGold
2 Replies

5. Shell Programming and Scripting

Read record from the text file contain multiple separated values & assign those values to variables

I have a file containing multiple values, some of them are pipe separated which are to be read as separate values and some of them are single value all are these need to store in variables. I need to read this file which is an input to my script Config.txt file name, first path, second... (7 Replies)
Discussion started by: ketanraut
7 Replies

6. Shell Programming and Scripting

Reading multiple values from multiple lines and columns and setting them to unique variables.

Hello, I would like to ask for help with csh script. An example of an input in .txt file is below, the number of lines varies from file to file and I have 2 or 3 columns with values. I would like to read all the values (probably one by one) and set them to independent unique variables that... (7 Replies)
Discussion started by: FMMOLA
7 Replies

7. Shell Programming and Scripting

Assigning multiple column's value from Oracle query to multiple variables in UNIX

Hi All, I need to read values of 10 columns from oracle query and assign the same to 10 unix variables. The query will return only one record(row). I tried to append all these columns using a delimiter(;) in the select query and assign the same to a single variable(V) in unix. I thought I... (3 Replies)
Discussion started by: hkrishnan91
3 Replies

8. UNIX for Dummies Questions & Answers

Read in Multiple log files and output selected variables and values to cvs file

I have several problems with my problems: I hope you can help me. 1) the If else statement I am getting an error message. My syntax must be incorrect because the entire statement is throwing an error. For example in filew.log if these items don't exist Memsize, SASFoundation and also if... (0 Replies)
Discussion started by: dellanicholson
0 Replies

9. Shell Programming and Scripting

awk to extract multiple values from file and add two additional fields

In the attached file I am trying to use awk to extract multiple values and create the tab-delimited desired output. In the output R_Index is a the sequential # and Pre_Enrichment is defaulted to .. I can extract from the values to the side of the keywords, but most are above and I can not... (2 Replies)
Discussion started by: cmccabe
2 Replies

10. Shell Programming and Scripting

Enhance existing script: Extract Multiple variables & Input in an echo string

Hi Experts I need your help to optimize my script to execute better as I have nearly 1M records & the script is taking close to 40 minutes to execute, so would need support on a faster alternative. Input: file {"house":"1024","zip":"2345","city":"asd","country":"zzv"}... (2 Replies)
Discussion started by: nk1984
2 Replies
Module::Manifest::Skip(3pm)				User Contributed Perl Documentation			       Module::Manifest::Skip(3pm)

NAME
Module::Manifest::Skip - MANIFEST.SKIP Manangement for Modules SYNOPSIS
From the command line: > perl -MModule::Manifest::Skip=create From Perl: use Module::Manifest::Skip; use IO::All; my $mms = Module::Manifest::Skip->new; # optional add and removes: $mms->add('^foo-bar$'); $mms->remove('^foo$'); $mms->remove(qr/Qfoo/); io('MANIFEST.SKIP')->print($mms->text); DESCRIPTION
NOTE: This module is mostly intended for module packaging frameworks to share a common, up-to-date "MANIFEST.SKIP" base. For example, Module::Install::ManifestSkip, uses this module to get the actual SKIP content. However this module may be useful for any module author. CPAN module authors use a MANIFEST.SKIP file to exclude certain well known files from getting put into a generated MANIFEST file, which would cause them to go into the final distribution package. The packaging tools try to automatically skip things for you, but if you add one of your own entries, you have to add all the common ones yourself. This module attempts to make all of this boring process as simple and reliable as possible. Module::Manifest::Skip can create or update a MANIFEST.SKIP file for you. You can add your own entries, and it will leave them alone. You can even tell it to not skip certain entries that it normally skips, although this is rarely needed. USAGE
Usually this module is called by other packaging modules. If you want this to be used by Module::Install, then you would put this: manifest_skip 'clean'; in your Makefile.PL, and everything would be taken care of for you. If you want to simply create a MANIFEST.SKIP file from the command line, this handy syntax exists: > perl -MModule::Manifest::Skip=create BEHAVIOR
This module ships with a share file called share/MANIFEST.SKIP. This is the basis for all new MANIFEST.SKIP files. This module will look for an already existing MANIFEST.SKIP file and take all the text before the first blank line, and prepend it to the start of a new SKIP file. This allows you to put your own personal section at the top, that will not be overwritten later. It will then look for lines beginning with a dash followed by a space. Like this: - foo - ^bar/ - ^baz$ It will comment out each of these lines and any other lines that match the text (after the '- '). This allows you to override the default SKIPs. AUTHOR
Ingy doet Net COPYRIGHT AND LICENSE
Copyright (c) 2011. Ingy doet Net. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.14.2 2011-10-08 Module::Manifest::Skip(3pm)
All times are GMT -4. The time now is 01:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy