append a string to a grep result


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting append a string to a grep result
# 1  
Old 03-19-2008
append a string to a grep result

hello,

iostat -En | grep Vendor | grep -v DV | awk '{print $1 $2}' | sort -u

returns

Vendor:HP

I want to append Disk to it. i.e.:

Disk Vendor:HP
how to do that?
thanks
# 2  
Old 03-19-2008
Try:
Code:
iostat -En|awk '/Vendor/ && !/DV/ && !a[$1]++{print "Disk "$1 $2}'

# 3  
Old 03-19-2008
append_vendor=Disk`iostat -En | grep Vendor | grep -v DV | awk '{print $1 $2}' | sort -u`

echo $append_vendor

append_vendor would have DiskVendor
# 4  
Old 03-19-2008
nua that's a perfect example of Useless Use of Grep + sort + echo....
# 5  
Old 03-19-2008
hi,

bash$ iostat -En|awk '/Vendor/ && !/DV/ && !a[$1]++{print "Disk "$1 $2}'

awk: syntax error near line 1
awk: bailing out near line 1

any idea please?

thanks.
# 6  
Old 03-19-2008
hi, could u post the result of the following command:

Code:
uname -a

BTW , use:

Code:
iostat -En|awk '/Vendor/ && !/DV/ && !a[$2]++{print "Disk "$1 $2}'

# 7  
Old 03-19-2008
same result for the 2nd command

I am using Solaris 8 and 10

Also note that this works perfectly:

iostat -En|awk '/Vendor/ && !/DV/ {print "Disk "$1 $2}'
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append result in the same line

I have a line like below a,blank,12,24 I want to add (12+24) at the end of the line or any where in the same line line output: a,blank,12,24,36 (2 Replies)
Discussion started by: Anjan1
2 Replies

2. Shell Programming and Scripting

Find string in file and append new string after

Hi All, I'm trying to insert a string into a file at a specific location. I'd like to add a string after the parent::__construct(); in my file. <?php if (! defined('BASEPATH')) exit('No direct script access allowed'); class MY_Controller extends CI_Controller { function... (6 Replies)
Discussion started by: jjkilpatrick
6 Replies

3. Shell Programming and Scripting

Append a searched string with another string using sed

Hi, I need to replace and append a string in a text if grep is true. For eg: grep ABC test.txt | grep -v '\.$' | awk {'print $4'} | sed "s/ ? How do I replace all instances of "print $4" using sed with another sring? Eg of the string returned will be, lx123 web222 xyz Want to... (8 Replies)
Discussion started by: vchee
8 Replies

4. UNIX for Dummies Questions & Answers

Bash - CLI - grep - Passing result to grep through pipe

Hello. I want to get all modules which are loaded and which name are exactly 2 characters long and not more than 2 characters and begin with "nv" lsmod | (e)grep '^nv???????????? I want to get all modules which are loaded and which name begin with "nv" and are 2 to 7 characters long ... (1 Reply)
Discussion started by: jcdole
1 Replies

5. UNIX for Dummies Questions & Answers

Append a string on the next line after a pattern string is found

Right now, my code is: s/Secondary Ins./Secondary Ins.\ 1/g It's adding a 1 as soon as it finds Secondary Ins. Primary Ins.: MEDICARE B DMERC Secondary Ins. 1: CONTINENTAL LIFE INS What I really want to achieve is having a 1 added on the next line that contain "Secondary Ins." It... (4 Replies)
Discussion started by: newbeee
4 Replies

6. Shell Programming and Scripting

Append Text in Result File Name

Hi Below command is returning the list of files which having this string "MTL_SYSTEM_ITEMS". find . -name "*"|xargs grep -il MTL_SYSTEM_ITEMS Ex: Above command is returing 2 files (Out of 10 files 2 files having this string). ./file1.txt and ./file2.txt Here I want to append... (3 Replies)
Discussion started by: balajiora
3 Replies

7. Shell Programming and Scripting

Grep for a string and then grep using a string from that result

Hello, Thanks in advance for the query. There is a log file abcd.log which has multible line like this. "hello1" , "hello2", "hello3" , "hello4" , "hello5" I want to grep for the lines which has "hello4" & "hello5" and use "hello2" to grep the same log file again. All these should... (8 Replies)
Discussion started by: kzenthil
8 Replies

8. Shell Programming and Scripting

Sending/append result from CSH script to xls file

Hi, 1st post... Done a quick search for this so apologies if I've missed it. Basically I want to output and and append several values generated by a csh script direct to an xls openoffice file, rather than send to txt file and then physically copy and paste to xls file. Already I send... (4 Replies)
Discussion started by: scottyjock
4 Replies

9. UNIX for Dummies Questions & Answers

Any way to grep a string in directories and return the result with diskusage aswell?

What Im basically trying to do is this: I have a small script that can grep any parameter entered into a search string, then print to the screen the name of each file the parameter appears in as well as the file path, ie the directory. The code Im using just for this is.... Directory... (3 Replies)
Discussion started by: Eddeh
3 Replies

10. Shell Programming and Scripting

Search a string and append text after the string

Hi, I have a file like this... <o t="Batch" id="8410" p="/" g="32"> <a n="name"> <v s="DBBA1MM"/> </a> <a n="owner"> <v r="/Administrator"/> </a> <a n="rights"> <v s="95"/> </a> <a n="debugLevel"> <v s="3"/> </a> <a n="avsStoreLoc"> <v... (8 Replies)
Discussion started by: kesu2k
8 Replies
Login or Register to Ask a Question