how to cut from output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to cut from output
# 1  
Old 04-16-2009
how to cut from output

Hi

How do i cut from this output so i only get db name

ps -ef |grep smon

oracle 29375 1 0 Nov 9 ? 8:08 ora_smon_HWEX62


i.e only want HWEX62

also bearling in mind that some database have been running from hours and some servers have different time and date formats

i.e

oracle 5917 1 0 18:32:18 ? 12:33 ora_smon_REPORT
# 2  
Old 04-16-2009
Quote:
Originally Posted by eb222
Hi

How do i cut from this output so i only get db name

ps -ef |grep smon

oracle 29375 1 0 Nov 9 ? 8:08 ora_smon_HWEX62


i.e only want HWEX62

also bearling in mind that some database have been running from hours and some servers have different time and date formats

i.e

oracle 5917 1 0 18:32:18 ? 12:33 ora_smon_REPORT

Try this:

Code:
value="oracle 29375     1  0  Nov  9  ?         8:08 ora_smon_HWEX62"
databasename=`echo ${value} | cut -d " " -f9 | cut -d "_" -f3`

echo $databasename


I may have got the 'f' wrong but its a start...
# 3  
Old 04-16-2009
Code:
ps -ef | grep smon | awk -F_ '{print $(NF)}'

# 4  
Old 04-16-2009
Quote:
Originally Posted by pludi
Code:
ps -ef | grep smon | awk -F_ '{print $(NF)}'

Code:
ps -ef | awk -F_ '/smon/{print $(NF)}'

# 5  
Old 04-16-2009
Or maybe :

Code:
ps -ef|awk -F_ '/[s]mon/{print$NF}'

# 6  
Old 04-16-2009
thanks i get below output

but how do i get rid of top and bottom lines so im only left with db name

$ ps -ef|awk -F_ '/[s]mon/{print$NF}'
client
root 1749 1 0 Jun 11 ? 0:00 /etc/opt/resmon/lbin/emsagent
EUP10ARS
root 29682 1076 0 Jan 8 ? 0:05 /etc/opt/resmon/lbin/registrar


$ ps -ef |grep smon
root 3372 1 0 Jun 11 ? 5066:34 /etc/opt/resmon/lbin/p_client
root 1749 1 0 Jun 11 ? 0:00 /etc/opt/resmon/lbin/emsagent
oracle 11365 1 0 Mar 26 ? 10:35 ora_smon_EUP10ARS
root 29682 1076 0 Jan 8 ? 0:05 /etc/opt/resmon/lbin/registrar
unixadm 18294 17788 1 18:06:45 pts/1 0:00 grep smon
# 7  
Old 04-16-2009
OK,
then try this:

Code:
ps -ef|awk -F_ '/[o]ra_smon/{print$NF}'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Assinging output of cut command

Hi, I have the files in the following files in a folder 19996587342 19487656550 19534838736 And i need to get the first 6 characters from the abvoe files so i used the following script #!/bin/ksh for i in 19* do txt= `$i | cut -c -6` echo "$txt" done The error is at... (4 Replies)
Discussion started by: smile689
4 Replies

2. Shell Programming and Scripting

Cut an output

Hi everyone, happy new year I have the following output: 2503 nteath 20 0 4892 312 2503 nteath 20 0 5872 312 2503 nteath 20 0 6852 312 2503 nteath 20 0 7832 312 2503 nteath 20 0 8812 312 2503 nteath 20 0 9792 312 2503 nteath 20... (3 Replies)
Discussion started by: nteath
3 Replies

3. Solaris

Send cut output to basename

Hi, I'm running a command : pargs 20392 | egrep -e "-f "|cut -d " " -f3 | basename BUT the o/p of cut is not sending to basename. the o/p of: pargs 20392 | egrep -e "-f "|cut -d " " -f3 is /home/staff/Properties.cfg Appreciated ur help.. (2 Replies)
Discussion started by: axes
2 Replies

4. Shell Programming and Scripting

ksh + isql => output cut at 2 GB

Using a ksh script, I'm dumping the data from our sybase database into an output file. This output file is for what ever reason cut at 2GB. There is enough space on the unix machine and as there is no error message is received I have no clue to start looking for a solution. #!... (1 Reply)
Discussion started by: bereman
1 Replies

5. UNIX for Dummies Questions & Answers

Cut an sql script output

Hi i want to cut the first field of this output obtained form sql script more dxlocks_test.log.1 SID SERIAL# SPID ---------- ---------- --------- 25 18356 1029 78 39370 1025 136 14361 1027 ================================ cut -f1... (2 Replies)
Discussion started by: aishwaryakala
2 Replies

6. UNIX for Dummies Questions & Answers

cut output on solaris9 and redhat

Hello, A file called test2 contains passwd entries from various servers. - On solaris9 host : > cat test1 | cut -d ":" -f3 | wc -l 18229 - The same file copied with scp to a redhat host (same cksum) : $ cat test1 | cut -d ":" -f3 | wc -l 39411 - A perl script running on the... (1 Reply)
Discussion started by: Krafton
1 Replies

7. Shell Programming and Scripting

how to cut off last column from the output

I have a problem with my script. I am using following code awk -F"," '{print $0,",",substr($2,3,3)}' $REG_InputFileName > $TargetSeqPath/Master.tmp while read i do echo $i > $TargetSeqPath/Ref.tmp OutFileName=`awk -F"," '{print $3}' $TargetSeqPath/Ref.tmp` rm -f... (9 Replies)
Discussion started by: manmeet
9 Replies

8. Shell Programming and Scripting

cut - columns with formatted Output

Hi I have the input file as below ***TEST10067 00567GROSZ 099 00567CTCTSDS90 ***TEST20081 08233GROZWEWE 00782GWERW899 ***TEST30088 08233GROZWEWE 00782GWERW899 I am finding the lines starting with *** and outputing as below TEST10067 TEST20081 TEST30088 I need a space between TEST1... (9 Replies)
Discussion started by: dhanamurthy
9 Replies

9. Shell Programming and Scripting

Cut output to same byte position

Hi folks I have a file with thousands of lines with fixed length fields: sample (assume x is a blank space) 111333xx444TTTLKOPxxxxxxxxx I need to make a copy of this file but with only some of the field positions, for example I'd like to copy the sample to the follwing: so I'd like to... (13 Replies)
Discussion started by: HealthyGuy
13 Replies

10. UNIX for Dummies Questions & Answers

How can I cut output of command??

I am on a Linux system using bash shell. I only want to see the number in the Use% field as the output. #df -h / Filesystem Size Used Avail Use% Mounted on /dev/dasda1 2.3G 2.1G 51M 98% / !#/bin/bash df -h / | awk '{print $5}' | cut -c1-2 Us 98 How do... (2 Replies)
Discussion started by: darthur
2 Replies
Login or Register to Ask a Question