Query cut informacion


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Query cut informacion
# 1  
Old 02-15-2016
Query cut informacion

query
Code:
pgrep -lf ora_pmon |
>  while read p a; do
>  printf '%s %-15s => %s\n' "$p" "$a" \
>  "$( dbhome "${a#ora_pmon_}" )"
> done

Code:
10286 ora_pmon_bd1 => /oracle/10.2
10431 ora_pmon_bd2 => /oracle/10.2
11728 ora_pmon_bd3 => /oracle/10.2
11882 ora_pmon_bd4 => /oracle/10.2
12068 ora_pmon_bd5 => /oracle/10.2

can help me
to get this result

Code:
bd1
bd2
bd3
bd4
bd5


Last edited by Scrutinizer; 02-15-2016 at 04:46 PM.. Reason: code tags
# 2  
Old 02-15-2016
I don't get it. Isn't the solution already in your script?

Code:
$ a=ora_pmon_bd1
$ echo "${a#ora_pmon_}"
bd1

# 3  
Old 02-15-2016
hello Scrutinizer.

in my script I have this result:

Code:
10286 ora_pmon_bd1 => /oracle/10.2
10431 ora_pmon_bd2 => /oracle/10.2
11728 ora_pmon_bd3 => /oracle/10.2
11882 ora_pmon_bd4 => /oracle/10.2
12068 ora_pmon_bd5 => /oracle/10.2

but i need this result

Code:
bd1
bd2
bd3
bd4
bd5


I hope to explain well

thanks

Last edited by Don Cragun; 02-15-2016 at 08:57 PM.. Reason: Add CODE tags again.
# 4  
Old 02-15-2016
Try changing:
Code:
pgrep -lf ora_pmon |
>  while read p a; do
>  printf '%s %-15s => %s\n' "$p" "$a" \
>  "$( dbhome "${a#ora_pmon_}" )"
> done

to:
Code:
pgrep -lf ora_pmon |
while read p a; do
    x="$( dbhome "${a#ora_pmon_}" )"
    printf '%s\n' "${x##*_}"
done

# 5  
Old 02-16-2016
Try:
Code:
pgrep -lf ora_pmon |
while read p a; do
  printf '%s\n'"${a#ora_pmon_}"
done

Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using :<<cut / cut to comment out block of bash script

I am using : << cut / cut to comment out block of code. Works fine on few lines of script, then it gives me this cryptic error when I try to comment out about 80 lines. The "warning " is at last line of script. done < results 169 echo "END read all positioning parameters" 170... (8 Replies)
Discussion started by: annacreek
8 Replies

2. UNIX for Beginners Questions & Answers

Cut command: can't make it cut fields

I'm a complete beginner in UNIX (and not a computer science student either), just undergoing a tutoring course. Trying to replicate the instructions on my own I directed output of the ls listing command (lists all files of my home directory ) to My_dir.tsv file (see the screenshot) to make use of... (9 Replies)
Discussion started by: scrutinizerix
9 Replies

3. Shell Programming and Scripting

Shell Script to execute Oracle query taking input from a file to form query

Hi, I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database. For instance: USER CITY --------- ---------- A CITY_A B CITY_B C ... (2 Replies)
Discussion started by: DevendraG
2 Replies

4. Shell Programming and Scripting

Cut Command error cut: Bad range

Hi Can anyone what I am doing wrong while using cut command. for f in *.log do logfilename=$f Log "Log file Name: $logfilename" logfile1=`basename $logfilename .log` flength=${#logfile1} Log "file length $flength" from_length=$(($flength - 15)) Log "from... (2 Replies)
Discussion started by: dgmm
2 Replies

5. Shell Programming and Scripting

Query Oracle tables and return values to shell script that calls the query

Hi, I have a requirement as below which needs to be done viz UNIX shell script (1) I have to connect to an Oracle database (2) Exexute "SELECT field_status from table 1" query on one of the tables. (3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
Discussion started by: balaeswari
6 Replies

6. Shell Programming and Scripting

add the output of a query to a variable to be used in another query

I would like to use the result of a query in another query. How do I redirect/add the output to another variable? $result = odbc_exec($connect, $query); while ($row = odbc_fetch_array($result)) { echo $row,"\n"; } odbc_close($connect); ?> This will output hostnames: host1... (0 Replies)
Discussion started by: hazno
0 Replies
Login or Register to Ask a Question