need a part of output data as output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need a part of output data as output
# 1  
Old 03-30-2010
need a part of output data as output

HI Guys,

I need some expert help.. i have this below data as input

WHERE StartTime >= '2010-03-24 20:10:08'
AND username in('abc_xxx_yyy_01')

and output need is
just

in

appreciate your help on this !!!!

thanks you ...
# 2  
Old 03-30-2010
Just in as output? Weird, but you can try this:
Code:
sed -n 's/.* \(in\)(.*/\1/p' file

# 3  
Old 03-30-2010
Generally you'd use sed or awk to strip whatever you don't want. Something like

yourprog | sed 's/.* in//'

or

yourprog | sed 's/.* in/This is: /'
# 4  
Old 03-30-2010
Try this also:

grep 'in' file | awk -F '(' '{print $1}' | awk '{print $3}'
# 5  
Old 03-30-2010
Thank You ... can i use output in to a variable and then use in my if statement
# 6  
Old 03-30-2010
Yes. Try this:

a=`grep 'in' 5.txt | awk -F '(' '{print $1}' | awk '{print $3}'`
echo $a
# 7  
Old 03-30-2010
Thanks Guys !!! Suppose if i want to search for in( or in ( or in ( how to grep in one command with above sceniro...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Extract a part of grep output

Hi, On AIX 7 I have : grep 's_ohs_instance_loc' $CONTEXT_FILE <ohs_instance_loc oa_var="s_ohs_instance_loc">/u01/appl_top/env/fs1/FMW_Home/webtier/instances/EBS_web_env_OHS1</ohs_instance_loc> But I need only this part:... (4 Replies)
Discussion started by: big123456
4 Replies

2. Shell Programming and Scripting

Bash to calculate average of all files in directory and output by part of filename

I am trying to use awk to calculate the average of all lines in $2 for every file in a directory. The below bash seems to do that, but I cannot figure out how to capture the string before the _ as the output file name and have it be tab-delimeted. Thank you :). Filenames in... (3 Replies)
Discussion started by: cmccabe
3 Replies

3. Shell Programming and Scripting

Parsing XML (and insert data) then output data (bash / Solaris)

Hi folks I have a script I wrote that basically parses a bunch of config and xml files works out were to add in the new content then spits out the data into a new file. It all works - apart from the xml and config file format in the new file with XML files the original XML (that ends up in... (2 Replies)
Discussion started by: dfinch
2 Replies

4. Shell Programming and Scripting

dig-x: only part of the output is needed

Hi everyone, how can I get the highlighted text only? I am only concerned with the first line of the "AUTHORITY SECTION" (in red). thank you in advance (4 Replies)
Discussion started by: Abdulelah
4 Replies

5. Shell Programming and Scripting

How to extract one part from whole output

Hi All, I am trying to write a small shell programming to get db2 database size info. The command I am going to use is- db2 "CALL GET_DBSIZE_INFO(?, ?, ?, -1)" and the output of above command generally is- Value of output parameters -------------------------- Parameter Name :... (4 Replies)
Discussion started by: NARESH1302
4 Replies

6. Shell Programming and Scripting

Cutting Part of Output

Hello all I'm using bourne shell and need to figure out how to cut out a specific portion of some output. For example, my output from my command is: 12.12.52.125.in-addr.arpa name = hostname.domain.main.gov I need to get just the "hostname.domain.main.gov" part. What I'm trying... (9 Replies)
Discussion started by: lee.n.doan
9 Replies

7. Shell Programming and Scripting

Directing only part of a script's output to piped application

Is there a way to keep the output of a script displayed on the terminal when it's run by itself, but suspend part of that output and only have a specific part delivered when it's piped to another script or program? I'm thinking something like the following pseudocode: #!/bin/bash ... (1 Reply)
Discussion started by: trigg
1 Replies

8. Solaris

How to capture only some part of output when command executed??

Hi, When I execute this command prtdiag -v output sample : System clock frequency: 160 MHZ Memory size: 4GB ==================================== CPUs ==================================== E$ CPU CPU CPU Freq Size ... (4 Replies)
Discussion started by: vijaysachin
4 Replies

9. Shell Programming and Scripting

Redirecting part of output to stdout

Hi, I am trying to execute a command like this: find ./ -name "*.gz" -exec sh -c 'zcat {} | awk -f parse.awk' \; >> output If I want to print the filename, i generally use the -print argument to the find command but when I am redirecting the output to a file, how can I print just the... (2 Replies)
Discussion started by: Legend986
2 Replies

10. Shell Programming and Scripting

Set specific part in command output into variable

I am trying unsuccessfully to set into a variable a specific part of command output: The command output will be as: line 1: <varied> line 2: 2 options: option 1: Set view: ** NONE ** or option 2: Set view: <different_name_of_views_always_without_spaces> and I would like to get into... (7 Replies)
Discussion started by: orit
7 Replies
Login or Register to Ask a Question