Sponsored Content
Top Forums Shell Programming and Scripting Extracting data from a shell output? Post 302282810 by TECK on Monday 2nd of February 2009 12:24:11 AM
Old 02-02-2009
Thanks a lot guys!
This is what I have so far:
Code:
result=$($indexer delta | awk '/^total.*docs/ {printf "docs=%d size=%d", $2, $4; exit}')
eval $result
echo $docs

Output:
1953887

Is there a more compact way to write the $result line or to incorporate the eval into it? I'm new at shell scripting, thank you for understanding...

Ideally, I would like to have a function that does the job, because I want to use it for different indexes (ie. alpha, beta, delta, etc.):
Code:
indexer="/usr/bin/indexer"
function fetch_indexinfo()
{
	result=$($indexer $0 | awk '/^total.*docs/ {printf "docs=%d size=%d", $2, $4; exit}')
	eval $result
}

Not sure how write the function, honestly. I plan to use it this way:
Code:
fetch_indexinfo delta
echo $docs
echo $size

The function will execute the command, then grab for the outputted text the values I'm interested (like it does it now with the direct command).
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to assign sql output data to shell script variable

Hi Guys ! I am new to unix and want to find out how we can make sql statement data to shell script variable? Any help/suggestion is greatly appreciated -Chandra (1 Reply)
Discussion started by: kattics
1 Replies

2. Shell Programming and Scripting

urgent-extracting block data from flat file using shell script

Hi, I want to extract block of data from flat file. the data will be like this start of log One two three end of log i want all data between start of log to end of log i.e One two three to be copied to another file. This particular block may appear multiple times in same file. I... (4 Replies)
Discussion started by: shirish_cd
4 Replies

3. UNIX for Dummies Questions & Answers

Help with extracting data and plotting

I have attached a txt file, what I would like to be able to do is: 1. Extract Data from Columns labeled E/N and Ko into a new file 2. Then in the new file I would like to be able to plot E/N on the X axis and Ko on the y axis. 3. Lastly I would like to be able to extract multiple data sets and... (6 Replies)
Discussion started by: gingburg
6 Replies

4. Shell Programming and Scripting

Extracting data from https server with the help of unix shell script

There is a folder which can be accessed through URL by giving a particular Username and Password.Inside the folder there are few excel sheets.The excel sheets/folder need to be imported from there to unix box with the help of unix shell script. Can anyone help me?Does anyone have code for it?... (2 Replies)
Discussion started by: vanur
2 Replies

5. Shell Programming and Scripting

extracting data from a string

Hi there, I have a bunch of vlan tagged network interfaces that are named as follows e1000g111000 e1000g99001 e1000g3456000 nge2002 where the 'e1000g' and 'nge' parts of the name are the driver, the red and blue bits above define the VLAN and the last digit on the end defines the... (3 Replies)
Discussion started by: rethink
3 Replies

6. Shell Programming and Scripting

Extracting specific lines of data from a file and related lines of data based on a grep value range?

Hi, I have one file, say file 1, that has data like below where 19900107 is the date, 19900107 12 144 129 0.7380047 19900108 12 168 129 0.3149017 19900109 12 192 129 3.2766666E-02 ... (3 Replies)
Discussion started by: Wynner
3 Replies

7. Shell Programming and Scripting

extracting data

I have a txt file of the following format >ab_ qwerty >rt_ hfjkil >Ty2 hglashglkasghkf; >P2 aklhfklflkkgfgkfl >ui_ vnllkdskkkffkfkkf >we32 vksksjksj;lslsf'sk's's .... ..... I want to split this big file based on the header (>) (5 Replies)
Discussion started by: Lucky Ali
5 Replies

8. Shell Programming and Scripting

Extracting data from file-shell scripting--please help

hello friends, my file is like 123 |asd|asd|asd 123_1|awd|asw|asw 121 |wer|qwe|wee 124 |weq|qwe|iop 1_23 |bla|blh|bha 145 |ghj|jkl|ghj 146 |qwe|qwe|wer 154 |asd|wer|qw_e 134_5|qwe|wer|qw_e is their any solution to retrive only those lines which are having only 3 numerical letters... (20 Replies)
Discussion started by: PankajChawla
20 Replies

9. Shell Programming and Scripting

Help with extracting data within parentheses

This is my input file: a|b|c(ef)|g|h(km)|p My output file should look like: a|b|ef|g|km|p That is, pipe is the delimiter. The data within pipe must be displayed as it is but if it encounters any data within parentheses, then only the data within parentheses has to be displayed ( the data... (2 Replies)
Discussion started by: ksatish89
2 Replies

10. Shell Programming and Scripting

Run sql query in shell script and output data save as delimited text

I want to run sql query in shell script and output data save as delimited text (delimited text would be comma) Code: SPOOL_FILE=/pgedw/dan.txt SQL=/pgedw/dan.sql sqlplus -s username/password@myhost:port/servicename <<EOF set head on set COLSEP , set linesize 32767 SET TRIMSPOOL ON SET... (8 Replies)
Discussion started by: Jaganjag
8 Replies
dualcoax(1)						      General Commands Manual						       dualcoax(1)

NAME
dualcoax - determine impedance of a coaxial structure with two concentric dielectrics. SYNOPSIS
dualcoax D1 D2 D3 Er1 Er2 DESCRIPTION
dualcoax computes the impedaance of a dualcoaxial cable, with two concentric dielectrics, given the outside diameter of the inner conductor D1, the outside diameter of the inner dielectric D2, the outside diameter of the outer dielectric (which is also the inside diameter of the outer conductor) D3, as well as the relative permttivity of the inner dielectric Er1 and the outer dielectric Er2. FILES
dualcoax does not read/write any files. SEE ALSO
atlc(1) coax(1) create_bmp_for_circ_in_circ(1) create_bmp_for_circ_in_rect(1) create_bmp_for_microstrip_coupler(1) create_bmp_for_rect_cen_in_rect(1) create_bmp_for_rect_cen_in_rect_coupler(1) create_bmp_for_rect_in_circ(1) create_bmp_for_rect_in_rect(1) create_bmp_for_stripline_coupler(1) create_bmp_for_symmetrical_stripline(1) design_coupler(1) find_optimal_dimensions_for_microstrip_coupler(1) readbin(1) http://atlc.sourceforge.net - Home page http://sourceforge.net/projects/atlc - Download area /usr/local/share/atlc/docs/html-docs/index.html - HTML docs /usr/local/share/atlc/docs/qex-december-1996/atlc.pdf - theory paper /usr/local/share/atlc/examples - examples Dr. David Kirkby atlc-4.6.0 28th Oct 2003 dualcoax(1)
All times are GMT -4. The time now is 09:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy