Sponsored Content
Full Discussion: Grep output to awk command
Top Forums Shell Programming and Scripting Grep output to awk command Post 302918602 by Klashxx on Wednesday 24th of September 2014 11:24:42 AM
Old 09-24-2014
Just enclose the var in quotes:
Code:
awk -v var="`cat kk2 |grep "Makarand"`" 'BEGIN { if (var != "") {print var;exit;}}'

As @pilnet101 points , your code is getting messy. Smilie
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

pipe'ing grep output to awk

This script is supposed to find out if tomcat is running or not. #!/bin/sh if netstat -a | grep `grep ${1}: /tomcat/bases | awk -F: '{print $3}'` > /dev/null then echo Tomcat for $1 running else echo Tomcat for $1 NOT running fi the /tomcat/bases is a file that... (2 Replies)
Discussion started by: ziggy25
2 Replies

2. Shell Programming and Scripting

How to grep/awk/egrep two values for given output?

Dear Friends, I have a command which can result following output. Packet is: /var/adm/yyyy/pkt6043 Intended for network : /vob/repo I would like to retrive pkt6043 and /vob/repo using single command. Blue color test will be always contstant and red color text will be dynamic ... (2 Replies)
Discussion started by: baluchen
2 Replies

3. UNIX for Dummies Questions & Answers

Using grep output as input for sed command

Hi, I would like to know if this is possible, and if so what can i do to make this work. I would like to grep a line X from fileA and then use the output to replace a word Y in fileB. grep "line X" fileA | sed -e 's/Y/X/g' > outfile this statement does not work, as i do not know how to... (7 Replies)
Discussion started by: cavanac2
7 Replies

4. UNIX and Linux Applications

How to redirect grep command output to same file

Hi Everyone, Can anyone please tell me, how can I redirect the grep command output to same file. I am trying with below command but my original file contains no data after executing the command. $grep pattern file1 > file1 Kind Regards, Eswar (5 Replies)
Discussion started by: picheswa
5 Replies

5. Shell Programming and Scripting

grep only a string on command output

How can I grep exactly a string that has .,/ characters using grep? Example: I want to grep ONLY string1 and not string1.more or string1.more.evenmore #lsauth ALL|grep 'string1' All output: string1 <--- This is the only I want. string1.more string1.evenmore. more.string1... (4 Replies)
Discussion started by: iga3725
4 Replies

6. Shell Programming and Scripting

Formatting grep and awk output

Hi there. I have a very large file and I am trying to format it so that I can pull out certain pieces of data/info and report it in spreadsheet format/style. The file has ###### which will separate each line that will be listed in the spreadsheet. Whenever I find "No" at the end of a line I want... (7 Replies)
Discussion started by: kieranfoley
7 Replies

7. Shell Programming and Scripting

awk or grep to search one column and output the other

Hello, it would be great if someone can help me with the following: I want to search for the rows from fileA in column 1 of fileB and output column 2 of fileB if found in fileC. In the moment I search within the complete file. How can I change the code so only column 1 is searched? cat fileA... (7 Replies)
Discussion started by: Manyaka
7 Replies

8. Shell Programming and Scripting

Grep command output in tabular format

I have a grep command script which works fine and give the correct results but i wanted the output to be displayed in tabular format ? Is it possible to display the output in tabular format and as well direct them to some file. main script : #!/usr/bin/bash Start_Time=`date '+%m%d%y... (1 Reply)
Discussion started by: Optimus81
1 Replies

9. Shell Programming and Scripting

awk - grep particular word from output

Hi Experts, - Getting error while using it through a variable to get the PID, PID=42 # UNIX95=1 ps -e -o pcpu,pid,ppid,stime,etime,args | awk '{if ($2~"^42$") print $0}' 0.00 42 0 Feb 10 600-17:21:29 nfs_async_io - But when using with a variable it is not working . #... (6 Replies)
Discussion started by: rveri
6 Replies
wml::std::toc(3)						     EN Tools							  wml::std::toc(3)

=LT=define-tag toc_section endtag=required> =LT=set-var __i=0 /> =LT=while =LT=lt =LT=get-var __i /> %0 />> =LT=<get-var toc_style
/>*=LT=toc_style_type =LT=get-var __i /> />> =LT=increment __i />=LT=/while> <li*> %body =LT=set-var __i=0 /> =LT=while =LT=lt =LT=get-var __i
/> %0 />> =LT=/<get-var toc_style />> =LT=increment __i />=LT=/while> =LT=/define-tag> "
       "=LT=" "<"
    /> </when>

       #   Define the <HX> and <TOC_HX> container tags (X = 1...6) <set-var __i=1 /> <set-var __pad= /> <while <lt <get-var __i /> 7 />>
	   <subst-in-string " =LT=define-tag h<get-var __i /> endtag=required> =LT=h<get-var __i />* %attributes> =LT=toc_h<get-var __i />>
       %body =LT=/toc_h<get-var __i />> =LT=/h<get-var __i />*> =LT=/define-tag> "
	       "=LT=" "<"
	   />
	   <subst-in-string " =LT=define-tag toc_h<get-var __i/> endtag=required> =LT=preserve alt/> =LT=set-var alt=/> =LT=set-var
       %attributes/> =LT=a name="ToC=LT=get-var __TOCCNT/>">%body</a> {#ToC#: =LT=toc_section <get-var __i/>> <get-var __pad/> =LT=a
       href="#ToC=LT=get-var __TOCCNT/>"><strong> =LT=or =LT=get-var alt/> %body/> </strong></a> =LT=/toc_section> <get-var toc_eol/>
       :#ToC#} =LT=increment __TOCCNT/> =LT=restore alt/> =LT=/define-tag> "
	       "=LT=" "<"
	   />
	   <set-var __pad="<get-var __pad /><get-var toc_pad />" />
	   <increment __i /> </while>

       ##EOF## __END__

NAME
wml::std::toc - Table of Contents Generation SYNOPSIS
#use wml::std::toc [style={pre,nbsp,hspace,ul,ol} [type=...]] <toc> <hN>...</hN> <toc_hN ...>...</toc_hN> DESCRIPTION
This creates a table of contents which can be inserted at any point (even more than once) by the "<toc>" tag. The contents gets created out of all header tags ``"<hN>"'' where ``N'' also controls the indention in the table of contents. Alternatively you can use the "<toc_hN>" tags to insert its body (can be empty!) at the current location and into the Table Of Contents. If specified, the "alt" attribute is included into the ToC instead of the body. STYLES
You may specify any of the five styles "pre", "nbsp", "hspace", "ul" and "ol". The last two accept special options to render HTML lists. With "style=ol", you may choose types 1, "A", "a", "i" and "I" whereas "style=ul" provides "d", "c" and "s" for respectively discs, circles and squares. EXAMPLE
Below is an example to render the Table of Contents with HTML "<pre>" tag. #use wml::std::toc style=pre #use wml::std::page <page> <h1>Chapter 1</h1> <h2>Section 1</h2> <h2>Section 2</h2> <h1>Chapter 2</h1> <h2>Section 1</h2> <h2>Section 2</h2> <toc> Play and choose your favorite! #use wml::std::toc style=ol type=A1ai or #use wml::std::toc style=ul type=dssccc AUTHORS
Ralf S. Engelschall rse@engelschall.com www.engelschall.com Denis Barbier barbier@engelschall.com REQUIRES
Internal: P1, P2, P5, P6 SEE ALSO
HTML "<Hx>" "<UL>" "<OL>" tags. EN Tools 2014-04-16 wml::std::toc(3)
All times are GMT -4. The time now is 07:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy