Sponsored Content
Top Forums Shell Programming and Scripting Output of a Grep(Which already has a variable) into a Variabale Post 302788199 by baranisachin on Monday 1st of April 2013 08:53:46 AM
Old 04-01-2013
Output of a Grep(Which already has a variable) into a Variabale

Hi All,
I have a an array, in which i need to loop through all the variable and check each variable individually for a pattern.

For ex
Code:
#!/bin/ksh

set -A FileNames $(</Temp/AllNames)
echo "Total array elements :" ${#FileNames[*]}

for i in ${FileNames[@]}
do
# if the "${i} | grep Last" returns true for this then i have #to do some manipulations
#Something like below
Temp = `${i} | grep Last` 
 
done

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

capturing the output of grep as integer variable

Hi, I have an expression using grep and nawk that captures the ID number of a given Unix process. It gets printed to screen but I don't know how to declare a variable to this returned value! For example, ps -ef|grep $project | grep -v grep | nawk '{print $2}' This returns my number. How... (2 Replies)
Discussion started by: babariba
2 Replies

2. Shell Programming and Scripting

redirect the grep output into the variable

i want to redirect the grep output into the variable but i am not able to get it i tried veri=`grep -i $1 "${logdir}"* | grep -i adding | grep -iv equation | tail -1 | cut -d ':' -f 1` vari=$(grep -i $1 "${logdir}"* | grep -i adding | grep -iv equation | tail -1 | cut -d ':' -f 1) BUT NOT... (1 Reply)
Discussion started by: mail2sant
1 Replies

3. Shell Programming and Scripting

Put the output of grep in a variable

Hi, in a shell script how can I put the result of a grep command in a variable : myvariable=grep mystring myfilename Thank you. (3 Replies)
Discussion started by: big123456
3 Replies

4. Shell Programming and Scripting

Problem with assigning output of grep + awk to a variable

Hi All, I am getting the output for the following command when i run it on the unix console. --------------------------- grep `whoami` /etc/passwd | awk '{print ($1);}' | cut -d ":" -f3 ---------------------------- But i made it into a script and tried to print the variable, its... (5 Replies)
Discussion started by: meheretoknow
5 Replies

5. Shell Programming and Scripting

ENV Variabale changes are not retained

ENV varibles set using a script are not retailed once the script execution is done. But if the same ENV variable is set in command line, it is retained. Consider the below case $ cat ti export MDS_CODE_HOME=`pwd` echo $MDS_CODE_HOME rsamadde@pcasvs04 ~/R2ANew $ ti... (3 Replies)
Discussion started by: gogol
3 Replies

6. Shell Programming and Scripting

declaring a variabale as string type

I know that directly we can assign a string to a variable but is there any other way to declare a variable as string type. I am using tcsh shell where I am using a function which would return a value of string type but when I am using return keyword , it is returning only integer value.pls help. (3 Replies)
Discussion started by: maitree
3 Replies

7. Shell Programming and Scripting

using awk for setting variable but change the output of this variable within awk

Hi all, Hope someone can help me out here. I have this BASH script (see below) My problem lies with the variable path. The output of the command find will give me several fields. The 9th field is the path. I want to captured that and the I want to filter this to a specific level. The... (6 Replies)
Discussion started by: Cowardly
6 Replies

8. Shell Programming and Scripting

How to grep the desired output and output to a file?

currently I have process from a raw file to this stage ALTER TABLE "EXCEL_ADMIN"."TC_TXN_VOID" ADD CONSTRAINT "PK_TC_TXN_VOID" PRIMARY KEY ("TC_TXN_IID") ALTER TABLE "EXCEL_ADMIN"."TC_TXN_AMT" ADD CONSTRAINT "PK_TC_TXN_AMT" PRIMARY KEY ("TC_TXN_AMT_IID") ALTER TABLE... (10 Replies)
Discussion started by: jediwannabe
10 Replies

9. UNIX for Dummies Questions & Answers

How to have the output in grep?

Hi guys - I am trying to have a certain file display information horizontally divided by a pipe. for example file name: foo.dat has information like this: name1 name2 name3 namenamename4 namene5 I would like it to display like this: name1|name2|name3|namenamename4|namene5 ... (6 Replies)
Discussion started by: DallasT
6 Replies

10. UNIX for Advanced & Expert Users

Passing variable as input & storing output in other variable

I have a below syntax its working fine... var12=$(ps -ef | grep apache | awk '{print $2,$4}') Im getting expected output as below: printf "%b\n" "${VAR12}" dell 123 dell 456 dell 457 Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)
Discussion started by: sam@sam
5 Replies
Courier::Filter::Module::BlankBody(3pm) 		User Contributed Perl Documentation		   Courier::Filter::Module::BlankBody(3pm)

NAME
Courier::Filter::Module::BlankBody - Blank-body message filter module for the Courier::Filter framework SYNOPSIS
use Courier::Filter::Module::BlankBody; my $module = Courier::Filter::Module::BlankBody->new( response => $response_text, logger => $logger, inverse => 0, trusting => 0, testing => 0, debugging => 0 ); my $filter = Courier::Filter->new( ... modules => [ $module ], ... ); DESCRIPTION
This class is a filter module class for use with Courier::Filter. It matches a message if its body is blank or consists only of whitespace, which is a frequent symptom of stupid spammers. Constructor The following constructor is provided: new(%options): returns Courier::Filter::Module::BlankBody Creates a new BlankBody filter module. %options is a list of key/value pairs representing any of the following options: response A string that is to be returned literally as the match result in case of a match. Defaults to "Message body is blank". All options of the Courier::Filter::Module constructor are also supported. Please see "new" in Courier::Filter::Module for their descriptions. Instance methods See "Instance methods" in Courier::Filter::Module for a description of the provided instance methods. SEE ALSO
Courier::Filter::Module, Courier::Filter::Overview. For AVAILABILITY, SUPPORT, COPYRIGHT, and LICENSE information, see Courier::Filter::Overview. AUTHOR
Julian Mehnle <julian@mehnle.net> perl v5.14.2 2011-12-27 Courier::Filter::Module::BlankBody(3pm)
All times are GMT -4. The time now is 01:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy