Sponsored Content
Top Forums Shell Programming and Scripting Pull specific data from repetitive text? Post 302396813 by TECK on Friday 19th of February 2010 11:01:20 AM
Old 02-19-2010
Pull specific data from repetitive text?

Hi all,

I have a bit of a problem with a loop that extracts repetitive text.

Running /bin/index executable outputs this text to terminal:
Code:
testing index 'scanthread'...
collected 0 docs, 0.0 MB
total 0 docs, 0 bytes
total 0.012 sec, 0 bytes/sec, 0.00 docs/sec
testing index 'scanpost'...
collected 1 docs, 0.0 MB
sorted 0.0 Mhits, 97.6% done
total 1 docs, 28 bytes
total 0.016 sec, 1725 bytes/sec, 61.62 docs/sec
testing index 'scankeyword'...
collected 0 docs, 0.0 MB
total 0 docs, 0 bytes
total 0.002 sec, 0 bytes/sec, 0.00 docs/sec
total 14 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg

My goal is to eval the command and pull the blue values from text, in a loop, and print them as a set:
Code:
test_index()
{
	indexlist=$(
		$indexer --config $CONF_PATH --run $1 |
		awk '/^total.*docs.*bytes$/ {printf "records=%d size=%d\n", $2, $4}'
	)
	for index in $indexlist; do
		echo "$index $records $size"
	done
}

index[0]="scanthread"
index[1]="scanpost"
index[2]="scankeyword"
test_index "${index[*]}"

The first issue I have is: I don't know how to filter the index title with awk (i.e. 'scanthread', with or without quotes, it does not matters).
Second, if I print the $records in the loop, it will print 6 times (the wrong value), instead of 3?

Thanks for your help.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading data from a specific line in a text file

hello, I have got the following problem that I am hoping someone can help with please. 1. I have got the following text file (below) , the columns data are 'Test Day', 'Board', 'Betting Number'. TEXT FILE ============================================ 1 3 02-01-27-28-29-30 0 1... (1 Reply)
Discussion started by: jermaine4ever
1 Replies

2. Shell Programming and Scripting

Reading data from a specific line in a text file

Hello, I have a problem which is giving me headache for days, can some please help. Please see code and text fiel below. Please see text in red for the problem I am facing # Program gets an input x from user while read line ; do echo... (4 Replies)
Discussion started by: jermaine4ever
4 Replies

3. Shell Programming and Scripting

How do you use pull data from multiple lines to do a for statement?

Guys I am having a problem with being able to find missing monitors in a configuration check script I am trying to create for accountability purposes for managing a large number of systems. What I am trying to do is run a script that will look at the raw config data in a file and pull all the pool... (7 Replies)
Discussion started by: scottzx7rr
7 Replies

4. Shell Programming and Scripting

How pull the Data from the file and should be mailed

Hi All, I need to pull the data from a file from 2 set of directories & should be mailed. I have a code , it is failing for some reason. Do somebody correct me where my script is going wrong. Directories: 1st Set of Directory /176_PS/Transactions/**/syslog.log ** : prd1 prd2... (2 Replies)
Discussion started by: raghunsi
2 Replies

5. Shell Programming and Scripting

Need help in writing a script to create a new text file with specific data from existing two files

Hi, I have two text files. Need to create a third text file extracting specific data from first two existing files.. Text File 1: Format contains: SQL*Loader: Release 10.2.0.1.0 - Production on Wed Aug 4 21:06:34 2010 some text ............so on...and somwhere text like: Record 1:... (1 Reply)
Discussion started by: shashi143ibm
1 Replies

6. Shell Programming and Scripting

Pull specific lines from long file based on formula

For people who want to pull a number of lines from a long file using a specific formula n (number of iterations in a loop) a (offset number) b (stretch factor) example with n {1..100} for (( n=1; n<101; n++ )); do awk -v n=$n 'NR==a+(b*n)' a=0 b=1 inputfile >>outputfile (2 Replies)
Discussion started by: sgruenwald
2 Replies

7. Shell Programming and Scripting

pull out rows with specific criteria

Hi, I have a file with multiple columns and for column 5 I want to extract that row into another file if it is equal to or greater than a certain value. For example: FAR 4 5 7 LOP GAT 3 3 3 POL I want values that are greater than 5 for column 4. So the final file will look like... (1 Reply)
Discussion started by: phil_heath
1 Replies

8. Shell Programming and Scripting

Converting text files to xls through awk script for specific data format

Dear Friends, I am in urgent need for awk/sed/sh script for converting a specific data format (.txt) to .xls. The input is as follows: >gi|1234|ref| Query = 1 - 65, Target = 1677 - 1733 Score = 8.38, E = 0.6529, P = 0.0001513, GC = 46 fd sdfsdfsdfsdf fsdfdsfdfdfdfdfdf... (6 Replies)
Discussion started by: Amit1
6 Replies

9. Shell Programming and Scripting

[Solved] How can I pull specific information from PS?

I need to grab information from the output of the ps command. For each line of ps output that contains _progres -b I need to get the word that follows -p. The "-p" can be anywhere after "_progres -b". Using grep to select the correct lines is no problem (e.g. ps -ef|grep "_progres \-b|grep -v... (3 Replies)
Discussion started by: Papa Lee
3 Replies

10. Shell Programming and Scripting

How to read all data after a specific string from a text file ?

Hi, I have a file(input.txt) and trying to format as output.txt. See the attached file format. Note: This is a windows file (DOS format) and the commands are also going to execute on windows. Basically I am trying to capture all the data in between Local Group Memberships and Global Group... (10 Replies)
Discussion started by: Monoj2014
10 Replies
symcompact(1)						      General Commands Manual						     symcompact(1)

NAME
symcompact - string compaction for object files SYNOPSIS
symcompact [ object_name ... ] DESCRIPTION
symcompact reduces the symbol table size of an executable file. This is done by removing unnecessary overlay transfer vectors (text sym- bols beginning with a tilde). In a nonoverlaid program there is no need for both the underscore (_foo) and tilde (~foo) text symbol and only the underscore form is kept. For overlaid programs if the symbol is in the base segment the tilde form is not needed and again only the underscore form is preserved. Running symcompact typically reduces the kernel symbol table size by 250 or so symbols. It is possible to run both symcompact and strcompact to achieve an even higher degree of symbol and string table compaction. The normal sequence is to run symcompact first followed by strcompact. If symcompact runs out of memory it will be necessary to reverse the order and run symcompact a second time - see the BUGS note below. The user must have write permission to the object/executable file. symcompact writes to stderr the count of symbols removed from the symbol table. symcompact exits 0 if successful, and >0 if an error occurred. SEE ALSO
symcompact(1), symorder(1) BUGS
This program can partially negate the benefits of strcompact because multiple references to identical strings cause additional strings to be placed in the string table. Running strcompact again after running this program fixes this problem. The register local symbol type is removed from the executable/object file. Since the debugger really doesn't know how to deal with those symbols this is not much of a loss and saves quite a bit of space both in the symbol table and the string table. symcompact should not be run on .o files that will be passed to the linker. The linker will need the tilde form of the symbol if an over- laid executable is being created. 3rd Berkeley Distribution January 25, 1994 symcompact(1)
All times are GMT -4. The time now is 03:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy