Sponsored Content
Top Forums Shell Programming and Scripting Sum numeric columns contained in a plain text file Post 302860169 by gacanepa on Friday 4th of October 2013 08:52:21 PM
Old 10-04-2013
[SOLVED] Sum numeric columns contained in a plain text file

Quote:
Originally Posted by CarloM
There might be a SET option for it.

EDIT:
Try
Code:
SET ECHO OFF
SET VERIFY OFF
SET FEEDBACK OFF
SET PAGESIZE 0

Thank you very much!
I was almost there and couldn't understand why the text of the query was still being saved in the text file, until I read that the SET options are only good if you use it in a sql script (separate file) and then source to in the bash script, like so:
File query.sql:
Code:
SET ECHO OFF
SET VERIFY OFF
SET FEEDBACK OFF
SET PAGESIZE 0
SPOOL myfile.txt
SELECT field1, field2 FROM mytable;
SPOOL OFF
exit

Then in the bash script:
Code:
#!/bin/bash
sql @query sql

It worked like a charm!
This User Gave Thanks to gacanepa For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Selectable numeric text menu from file possible?

Is there a way i can take 'lets say the etc/group file' and arange the group names into a selectable numeric menu eg; 1) root:0 2) other:1 3) bin:2 4) sys:3 ..... ..... ..... and so on then GROUP="group name of users selection" i have tried for over an hour searching on... (6 Replies)
Discussion started by: switchkill
6 Replies

2. Shell Programming and Scripting

Sum of three columns - in 4N columns file

Hi All, happy new year. I have a file with 4xN columns like 0.0000e+00 0.0000e+00 7.199E+07 7.123E+07 6.976E+07 6.482E+07 5.256E+07 2.523E+07 0.0000e+00 0.0000e+00 8.641E+07 8.550E+07 8.373E+07 7.780E+07 6.309E+07 3.028E+07... (8 Replies)
Discussion started by: f_o_555
8 Replies

3. UNIX for Dummies Questions & Answers

Sum of all columns in all files in one output file

If I have say 4 files like this: File1: 1 3 4 7 7 0 5 7 5 9 1 2 7 4 8 File2: 1 4 6 2 5 7 1 2 3 6 0 3 0 3 8 File3: (5 Replies)
Discussion started by: cosmologist
5 Replies

4. Shell Programming and Scripting

To perform sum aggregation on numeric fields

Hi all, I have following scenario to perform sum aggregation on certain columns Node Allocated_Space Pool_Name CS_Group Utilized Space -------- ---------------- ---------- --------- -------------- bdw1a_lun01 300 bdw_p0 ... (2 Replies)
Discussion started by: ckwan
2 Replies

5. Shell Programming and Scripting

Sum of two columns in a file

Hi, I need to do a sum of two columns in a file where delimiter is |^ input 1|^2|^3|^4|^50|^2|^3|^100 2|^3|^4|^6|^100|^7|^2|^50 3|^4|^2|^3|^50|^6|^3|^50 4|^2|^5|^7|^25|^2|^8|^25 Output required: Sum of 2 columns 5 & 8 which is 450 (11 Replies)
Discussion started by: Jram
11 Replies

6. Shell Programming and Scripting

Modify one line in a plain text file

Hi everyone, I want to know, if there is a way to modify one line in a text file with unix script, with out re-writing all the file. For example, i have this file: CONFIGURATION_1=XXXX CONFIGURATION_2=YYYY CONFIGURATION_3=ZZZZ supose i have a command or function "modify" that... (7 Replies)
Discussion started by: Xedrox
7 Replies

7. Shell Programming and Scripting

Evaluate 2 columns, add sum IF two columns match on two rows

Hi all, I know this sounds suspiciously like a homework course; but, it is not. My goal is to take a file, and match my "ID" column to the "Date" column, if those conditions are true, add the total number of minutes worked and place it in this file, while not printing the original rows that I... (6 Replies)
Discussion started by: mtucker6784
6 Replies

8. Shell Programming and Scripting

Evaluate 2 columns, add sum IF two columns satisfy the condition

HI All, I'm embedding SQL query in Script which gives following output: Assignee Group Total ABC Group1 17 PQR Group2 5 PQR Group3 6 XYZ Group1 10 XYZ Group3 5 I have saved the above output in a file. How do i sum up the contents of this output so as to get following output: ... (4 Replies)
Discussion started by: Khushbu
4 Replies

9. UNIX for Beginners Questions & Answers

Copy columns from one file into another and get sum of column values and row count

I have a file abc.csv, from which I need column 24(PurchaseOrder_TotalCost) to get the sum_of_amounts with date and row count into another file say output.csv abc.csv- UTF-8,,,,,,,,,,,,,,,,,,,,,,,,, ... (6 Replies)
Discussion started by: Tahir_M
6 Replies

10. UNIX for Advanced & Expert Users

Need Optimization shell/awk script to aggreagte (sum) for all the columns of Huge data file

Optimization shell/awk script to aggregate (sum) for all the columns of Huge data file File delimiter "|" Need to have Sum of all columns, with column number : aggregation (summation) for each column File not having the header Like below - Column 1 "Total Column 2 : "Total ... ...... (2 Replies)
Discussion started by: kartikirans
2 Replies
RESET(7)							   SQL Commands 							  RESET(7)

NAME
RESET - restore the value of a run-time parameter to a default value SYNOPSIS
RESET variable RESET ALL INPUTS variable The name of a run-time parameter. See SET [set(7)] for a list. ALL Resets all settable run-time parameters to default values. DESCRIPTION
RESET restores run-time parameters to their default values. Refer to SET [set(7)] for details. RESET is an alternate spelling for SET variable TO DEFAULT The default value is defined as the value that the variable would have had, had no SET ever been issued for it in the current session. The actual source of this value might be a compiled-in default, the postmaster's configuration file or command-line switches, or per-database or per-user default settings. See the Administrator's Guide for details. See the SET manual page for details on the transaction behavior of RESET. DIAGNOSTICS
See under the SET [set(7)] command. EXAMPLES
Set DateStyle to its default value: RESET DateStyle; Set geqo to its default value: RESET GEQO; COMPATIBILITY
RESET is a PostgreSQL extension. SQL - Language Statements 2002-11-22 RESET(7)
All times are GMT -4. The time now is 05:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy