Need SQL output without the header.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need SQL output without the header.
# 1  
Old 02-11-2011
Need SQL output without the header.

Hi,

In a script i am trying to run a SQL by connecting Sybase DB.
While executing the script I am getting the output with the header. means:

Code:
Employee_Name--------------------------- Anup Das

I need the Output:

Code:
Anup Das

Kindly advice.
# 2  
Old 02-11-2011
Code:
awk '{print $(NF-1),$NF}'

# 3  
Old 02-13-2011
Quote:
Originally Posted by yinyuemi
Code:
awk '{print $(NF-1),$NF}'

If the employee name comprises of more than two words, then this script won't return the full name!

A better idea might be something like this -

Code:
$
$ echo "Employee_Name--------------------------- Gael Garcia Bernal" | awk '{sub(/^.*-+ /,""); print}'
Gael Garcia Bernal
$
$
$ echo "Employee_Name--------------------------- Henri de Toulouse-Lautrec" | awk '{sub(/^.*-+ /,""); print}'
Henri de Toulouse-Lautrec
$
$

tyler_durden
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Storing multiple sql queries output into variable by running sql command only once

Hi All, I want to run multiple sql queries and store the data in variable but i want to use sql command only once. Is there a way without running sql command twice and storing.Please advise. Eg : Select 'Query 1 output' from dual; Select 'Query 2 output' from dual; I want to... (3 Replies)
Discussion started by: Rokkesh
3 Replies

2. UNIX for Dummies Questions & Answers

Display header in script output

Hi -- Working on my own through the book "Learning the KornShell and came to task 4-1, which there is: a script "highest" and it will sort an "album" file. highest filename The author mentions adding a header line to the scripts output if the user types in the -h option. It says "assume the... (9 Replies)
Discussion started by: Decoy Octopus88
9 Replies

3. Shell Programming and Scripting

Manipulate all rows except header, but header should be output as well

Hello There... I have a sample input file .. number:department:amount 125:Market:125.23 126:Hardware store:434.95 127:Video store:7.45 128:Book store:14.32 129:Gasolline:16.10 I will be doing some manipulations on all the records except the header, but the header should always be... (2 Replies)
Discussion started by: juzz4fun
2 Replies

4. Shell Programming and Scripting

getting sql header from the script

i have the SQL as mentioned below. i put this sql in a file and calling from the script and output of SQL has been redirected to a file. but when i open the sql output file i dont see the header in sql output. how can i get the header also ? ==== SELECT RATE_CODE,NAME, CTR,TYPE ... (1 Reply)
Discussion started by: mail2sant
1 Replies

5. Shell Programming and Scripting

Awk script to run a sql and print the output to an output file

Hi All, I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file. Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies

6. Shell Programming and Scripting

How to Add Table with Header for Shell Output

I have a Script that generates 3 columns of the result. The line script is /usr/xpg4/bin/awk -F' ' '{print $1 /t $2}' File_Name | awk -F'>' '{print $2}' | cut -d'<' -f1 | sort -rn | uniq -c The output of the Command is : Code.500 4 Input Error Code.404 ... (4 Replies)
Discussion started by: raghunsi
4 Replies

7. Shell Programming and Scripting

Extract header from top command output

hi, I want to extract and save the cpu(s) information from top command output, but individual cpu statistics separately on a multi-processor machine. In command line, top will show this statistics when we press the switch "1". any ideas? thanks, meharo (3 Replies)
Discussion started by: meharo
3 Replies

8. Shell Programming and Scripting

getting the column header in the output !

i have a script that access the database and then returns some row. but in the command prompt it it not showing the column header. how to get that ? below the script: ------------------------------------------------------------------------ #!/bin/ksh .... (4 Replies)
Discussion started by: ali560045
4 Replies

9. Shell Programming and Scripting

help with header of sql

i have this script here.. text=/d:/...../1.txt ORACLE_HOME/bin/sqlplus -S............ ................................................... spool $text; select item || '|' || ord_no || '|' || price || '|' || from order_table The output header of this spooled data will be ... (4 Replies)
Discussion started by: forevercalz
4 Replies
Login or Register to Ask a Question