Concatenate output in shell script


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Concatenate output in shell script
# 1  
Old 04-10-2012
Concatenate output in shell script

Hi Colleagues,

I need the help in the followind.
I execute this.
Code:
select count(*) from schema.tablew

the output is this.
Code:
select count(*) from schema.table
       3955

I need the followind output.
Code:
select count(*) from schema.table        3955

Thank you for you help.

Last edited by Scrutinizer; 04-10-2012 at 03:38 PM.. Reason: Code tags..
# 2  
Old 04-10-2012
Your requirement is not very clear to me. I am guessing your output is like:
Code:
COUNT(*)
----------
3955

and you want it to be just 3955 so that you can store it in variable ? if so just add set head off at starting of your sql.
# 3  
Old 04-10-2012
Excuse me my english is very bad, I execute this statement.
Code:
select count(*) from schema.table

I need this output.
Code:
select count(*) from schema.table        3955

Thank you for advanced.

Last edited by Scrutinizer; 04-10-2012 at 03:39 PM.. Reason: code tags
# 4  
Old 04-10-2012
Code:
set pages 0
select 
  'select count(*) from schema.table ' ||  
  count(*) 
from 
  schema.table;

# 5  
Old 04-10-2012
When i execute this statements,
Code:
select count(*) from PP1.A0IMPRTD with UR;
select count(*) from PP1.PROPAGACIONES with UR;
select count(*) from PP1.A0SVCRTD with UR;
select count(*) from PP1.HIT_RATIO with UR;
select count(*) from PP1.A0IMGRTD with UR;
select count(*) from PP1.A0RUTATD with UR;
select count(*) from PP1.A0UNSSTD with UR;

Obtain this output is this.

Code:
select count(*) from PP1.A0IMPRTD with UR
 76
select count(*) from PP1.PROPAGACIONES with UR
60002
select count(*) from PP1.A0SVCRTD with UR 
25
select count(*) from PP1.HIT_RATIO with UR
22996
select count(*) from PP1.A0IMGRTD with UR 
225
select count(*) from PP1.A0RUTATD with UR
331594
select count(*) from PP1.A0UNSSTD with UR 
13124
select count(*) from PP1.OPTIMA_SERVICIOS with UR
5171
select count(*) from PP1.A0CONVTD with UR
 10997
select count(*) from PP1.A0MENSTD with UR
7219
select count(*) from PP1.A0TITRTD with UR
 6
select count(*) from PP1.A0TPARTD with UR
4
select count(*) from PP1.P60_INI with UR
 0
select count(*) from PP1.P60_FIN with UR
0

But i need this output.
Code:
select count(*) from PP1.A0IMPRTD with UR 76
select count(*) from PP1.PROPAGACIONES with UR 60002
select count(*) from PP1.A0SVCRTD with UR 25
select count(*) from PP1.HIT_RATIO with UR 22996
select count(*) from PP1.A0IMGRTD with UR 225
select count(*) from PP1.A0RUTATD with UR 331594
select count(*) from PP1.A0UNSSTD with UR 13124
select count(*) from PP1.OPTIMA_SERVICIOS with UR 5171
select count(*) from PP1.A0CONVTD with UR 10997
select count(*) from PP1.A0MENSTD with UR 7219
select count(*) from PP1.A0TITRTD with UR  6
select count(*) from PP1.A0TPARTD with UR 4
select count(*) from PP1.P60_INI with UR  0
select count(*) from PP1.P60_FIN with UR 0

Thank you for advanced.

Moderator's Comments:
Mod Comment Welcome to the UNIX and Linux Forums. Please use code tags. Video tutorial on how to use them

Last edited by Scrutinizer; 04-10-2012 at 03:37 PM..
# 6  
Old 04-10-2012
you should try the syntax mentioned by @radoulov in post#4
# 7  
Old 04-10-2012
Pass the input through this script:

Code:
sed 'N;s/\n/ /'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script to call and sort awk script and output

I'm trying to create a shell script that takes a awk script that I wrote and a filename as an argument. I was able to get that done but I'm having trouble figuring out how to keep the header of the output at the top but sort the rest of the rows alphabetically. This is what I have now but it is... (1 Reply)
Discussion started by: Eric7giants
1 Replies

2. Shell Programming and Scripting

A shell script to run a script which don't get terminated and send a pattern from the output by mail

Hi Guys, I am very new to shell script and I need your help here to write a script. Actually, I have a script abc.sh which don't get terminated itself. So I need to design a script to run this script, save the output to a file, search for a given string in the output and if it exists send those... (11 Replies)
Discussion started by: Sambit Sahu
11 Replies

3. Shell Programming and Scripting

Shell Script function to use script name for log file output

Hi Team - I"m very new to Shell Scripting so I have a rather novice question. My forte is Windows Batch Scripting so I was just wondering what the Shell Script equivalent is to the DOS command %~n? %~n is a DOS variable that dispayed the script name. For instance (in DOS): REM... (11 Replies)
Discussion started by: SIMMS7400
11 Replies

4. UNIX for Advanced & Expert Users

Concatenate lines in file shell script

Hi colleagues, I have a file in this format. "/cccc/pppp/dddd/ggg/prueba.txt". ERROR" THE error bbbbbbbbbb finish rows. "/kkkk/mmmm/hhhh/jjj/ejemplo.txt". ERROR This is other error rows.I need my file in this format. "/cccc/pppp/dddd/ggg/prueba.txt". ERROR" THE error bbbbbbbbbb finish rows.... (3 Replies)
Discussion started by: systemoper
3 Replies

5. UNIX for Dummies Questions & Answers

Read rows from source file and concatenate output

Hi guys; TBH I am an absolute novice, when it comes to scripting; I do have an idea of the basic commands... Here is my problem; I have a flatfile 'A' containing a single column with multiple rows. I have to create a script which will use 'A' as input and then output a string in in the... (0 Replies)
Discussion started by: carlos_anubis
0 Replies

6. Shell Programming and Scripting

Concatenate piped output and some var?

Hello, There is pipe chain and I want concacenate piped data with some variable: balh blah| ... $var1 What command I should use instead ... to concatenate piped output with $var1. I think I coud solve this using temp var - but could it be done in one line like sample above ? thanks... (4 Replies)
Discussion started by: vilius
4 Replies

7. Shell Programming and Scripting

concatenate lines using shell scripting

i have a mega file in this format: a, b, c, d, = a2, b2, c2, d2, = a3, b3 = i want to combine lines until = meet. the result should be : a,b,c,d, a2,b2,c3,d2 a3,b3 (13 Replies)
Discussion started by: dtdt
13 Replies

8. Shell Programming and Scripting

[How To?] Run shell script and get output into another shell.

Hi guys, I have a simple question, I want to store the output of the following command: As you can see it is running all the time, and we get a new line every 3sec. I just want to store these new lines into a single variable, so I can use it into a script. To clear the screen, and... (4 Replies)
Discussion started by: Thireus
4 Replies

9. Shell Programming and Scripting

Help with a shell script to concatenate lists together

Below is a description of what im trying to achieve: Write a shell script to concatenate lists together, and output the resulting list. Do not include any argument that is a sub-list of the entire list. (The script will clean the list of any redundant items.) You must preserve the original order... (1 Reply)
Discussion started by: rfourn
1 Replies

10. Shell Programming and Scripting

How to cut, concatenate data in Shell Script

Hello All,, I'm very new to Unix and I'm more in SAP ABAP. I have a requirement for a shell script which will accept one parameter as Input file name(with directory) e.g : /sapdata/deubank/dbdirect/out/deu01deupe/in/deu01deupe20051207111320.pmt In the shell script I have to make two more... (2 Replies)
Discussion started by: vasan_srini
2 Replies
Login or Register to Ask a Question