Selecting a string


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Selecting a string
# 1  
Old 01-27-2009
Selecting a string

Hi,

I have a small question... Since i am new to Unix ksh scripting i am having this problem of understanding...
Well the thing is that i just want a part of a line for example

Code:
Data Set=ELIG_Member_20090126.dat Count Total= 8192 Actual Total= 8187

I just want the value of Actual Total ie 8187

My code.. i mean till where i wrote looks up for line Data Set line and currently printing whole line... now i just want the value of Actual Total only ie 8187 for the line

Code:
grep "${3}" ${LOG_DIR}/${CUR_MAINT_DATE}/${filnam}_200*log | head -1

Here {3}= Data Set

Can any one say me what change i have to do in my grep so it will just get me the value of actual total

Thanks for helping me

Bhagya
# 2  
Old 01-27-2009
Just pipe the output of that line into awk:

awk -F "Actual Total=" '{print $2}'
# 3  
Old 01-27-2009
Thanks a lot... it worked... But actually i have something else to add to that value
The output should be 8187,
There should be a coma beside the value... how can i get that....

Last edited by bhagya2340; 01-27-2009 at 01:06 PM..
# 4  
Old 01-27-2009
Change the print command to:

'{print $2","}'
# 5  
Old 01-27-2009
Thanks a lot... You are the best...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Selecting groups

I have a file with contents like host1.domain.com:9090,host2.domain.com:9090,host3.domain.com:9090 I am looking for such an operation so that, the output should be host1.domain.com:9090 host2.domain.com:9090 host3.domain.com:9090 And also, if the number of entries are more, the... (1 Reply)
Discussion started by: anil510
1 Replies

2. Shell Programming and Scripting

Selecting tables

Hi, Can anyone help me that, How to see the table fields in Oracle database through shell script(ksh). I have tried with the following: sqlplus -s $user/$passwd@$sid << SQL >> session.log select * from Testtab.sql I'm not able to see anything.. Thanks (4 Replies)
Discussion started by: zxcjggu708
4 Replies

3. Shell Programming and Scripting

selecting certain files

Hi, I have been working on a punch of codes and I got to a problem I hope to get help on. I have some files that I want to work with but the folder has other files in it. For example: The folder contains these files: path to files: /home/distribution/ ls: b.10; b.11; b.12; b.20; b.222;... (2 Replies)
Discussion started by: iconig
2 Replies

4. Shell Programming and Scripting

Selecting data between [ and ]

Hi Team, I am searching through log file using grep -i '<search_key>' <file_name>|awk '{print $18}' example outputs are I would like to select the data between and no other as I am getting some junk characters sometimes which chaging the o/p display format. Kindly assist.... (8 Replies)
Discussion started by: sanjaydubey2006
8 Replies

5. Shell Programming and Scripting

[Solved] Need Help on Selecting a particular record

Hi Guys, Following is my Input file. Time : Wed Nov 16 02:32:09 2011 Type : INFO User : dsadm Message : Oracle_Connector_2: The connector generated the following TRUNCATE TABLE statement at runtime: TRUNCATE TABLE CANADA_INDUSTRY_OBJECTIVES. Time : Wed Nov 16... (4 Replies)
Discussion started by: mac4rfree
4 Replies

6. Shell Programming and Scripting

about selecting lines

Hello , i got text file like that' C:\Users\Public\Pictures\Sample Pictures\aa.jpg C:\Users\Public\Pictures\Sample Pictures\thumb.jpg C:\Users\Public\Pictures\vv\cc.jpg C:\Users\Public\Pictures\Sample Pictures\ee.jpg C:\Users\Public\aa\Sample Pictures\cvswsr.jpg... (1 Reply)
Discussion started by: davidkhan
1 Replies

7. Shell Programming and Scripting

selecting tokens from a string...

i store the output of ls in a variable FL $FL=`ls` $echo $FL f1.txt f2.txt f3.txt f4.txt f5.txt script.sh script.sh~ test.txt now if i want to retrive the sub-string "f1.txt" from $FL we were taught that this is what i have to do $set $FL $echo $1 f1.txt and echo $2 would give... (1 Reply)
Discussion started by: c_d
1 Replies

8. Shell Programming and Scripting

Selecting one file from a list

Hi, I am able to do this by brute force but I am just curious if there is a better way of handling things. Basically the scenario is something like this: There are a number of files in a directory: rib.20071224.1759.gz 24-Dec-2007 17:59 132K rib.20071224.1959.gz 24-Dec-2007... (7 Replies)
Discussion started by: Legend986
7 Replies

9. Shell Programming and Scripting

Selecting a line value

Hello, I just wanted to know if there is a way in UNIX to select a line value from a list of words. there is no line number before each word, hence could not use grep. (4 Replies)
Discussion started by: unibboy
4 Replies

10. UNIX for Dummies Questions & Answers

Selecting unknown string.

Work problem: Need to set up a job to periodically check that the number of entries in the mail queue. I'm able to do the following: mailq | grep "Mail Queue" Which returns: Mail Queue (7 requests) Unfortunately I'm not sure how I select between `(` and `requests`? ... (2 Replies)
Discussion started by: Cameron
2 Replies
Login or Register to Ask a Question