Sponsored Content
Full Discussion: Subtotal in UNIX
Top Forums Shell Programming and Scripting Subtotal in UNIX Post 302901778 by gandolf989 on Thursday 15th of May 2014 02:45:45 PM
Old 05-15-2014
What is the delimiter? If it is space delimited and you have spaces in the first field, then you won't be able to properly parse the file. You should use either : or ~ to delimit the fields. If you change the delimiter you can probably use cut such as

for line in `cat data.dat`
do
echo "column 1: "+`echo ${line} | cut -d":" | -f1`
echo "column 2: "+`echo ${line} | cut -d":" | -f2`
echo "column 3: "+`echo ${line} | cut -d":" | -f3`
done

I have not yet run the above code to check for bugs.
You will need to take the logic and change it for what you need.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

UNIX problem? Unix programm runs windows 2000 CPU over 100%

Okee problems...!! What is happening: Unix server with some programms, workstations are windows 2000, the workstations work good but when you start a programm on the Unix server the CPU of the workstations go to 100% usage resulting that the system gets very slow. The programm well its running so... (2 Replies)
Discussion started by: zerocool
2 Replies

2. UNIX for Advanced & Expert Users

missing Path(in UNIX) when i launch a job on to unix machine using windows SSh

hi i want run an unix application from a windows program/application.i am using SSH(command line version)to log on to a unix machine from windows. the application has to read a configuration file inorder to run. the configuration file .CFG is in bin in my home directory. but the application... (1 Reply)
Discussion started by: megastar
1 Replies

3. Shell Programming and Scripting

FTP script for sending a file from one unix directory to another unix server director

Hi, My local server is :/usr/abcd/ Remote server is :/Usr/host/test/ I want to send files from local unix directory(All files starting with O_999) to remote host unix directory. Can any body give me the Unix Shell script to do this. One more doubt: Shall we need to change the file... (1 Reply)
Discussion started by: raja_1234
1 Replies

4. Shell Programming and Scripting

subtotal columns

Hello I have a file that has two (or more) different types of records I want to total. How would I do this using awk? The file may contain several dozen records. The records are sorted on the database column - what I want to do is get the amount of space that each table has in that database... (5 Replies)
Discussion started by: stonemonolith
5 Replies

5. Shell Programming and Scripting

Batch job in unix server to move the pdf file from unix to windows.

Hi Experts, I have a requirement where i need to setup a batch job which runs everymonth and move the pdf files from unix server to windows servers. Could some body provide the inputs for this. and also please provide the inputs on how to map the network dirve in the unix like that... (1 Reply)
Discussion started by: ger199901
1 Replies

6. UNIX for Dummies Questions & Answers

How do you subtotal lines in a file? Awk?

I have a file with 8 fields. I need the subtotals for fields 7 & 8 when field 5 changes. cat wk1 01/02/2011/18AB/17/18/000000071/000000033 01/02/2011/18AB/17/18/000000164/000000021 01/02/2011/18AB/17/18/000000109/000000023 01/02/2011/28FB/04/04/000000000/000000000... (2 Replies)
Discussion started by: MS75001
2 Replies

7. UNIX for Dummies Questions & Answers

How does unix system administration, unix programming, unix network programming differ?

How does unix system administration, unix programming, unix network programming differ? Please help. (0 Replies)
Discussion started by: thulasidharan2k
0 Replies

8. Shell Programming and Scripting

File Transfer from Window server to UNIX and UNIX to UNIX

Dear All, Can someone help to command or program to transfer the file from windows to Unix server and from one unix server to another Unix server in secure way. I would request no samba client. (4 Replies)
Discussion started by: yadavricky
4 Replies

9. Shell Programming and Scripting

How to add subtotal and total according 3rd field mentioned below table?

111AKKK|SHA|20|25 111|AKKK|SHA|15|35 112|ABC|FL|25|45 112|ABC|FL|15|15 115|AKKK|ASH|10|15 115|AKKK|ASH|20|20 112|ABC|FL|25|20 115|AKKK|ASH|30|35 111|AKKK|SHA|10|45 112|ABC|KL|15|15 112|ABC|KL|20|25 115|AKKK|ASH|30|35 please write a shell script output should be below mentioned... (26 Replies)
Discussion started by: udhal
26 Replies
CUBRID_PREPARE(3)							 1							 CUBRID_PREPARE(3)

cubrid_prepare - Prepare a SQL statement for execution

SYNOPSIS
resource cubrid_prepare (resource $conn_identifier, string $prepare_stmt, [int $option]) DESCRIPTION
The cubrid_prepare(3) function is a sort of API which represents SQL statements compiled previously to a given connection handle. This pre-compiled SQL statement will be included in the cubrid_prepare(3). Accordingly, you can use this statement effectively to execute several times repeatedly or to process long data. Only a single statement can be used and a parameter may put a question mark (?) to appropriate area in the SQL statement. Add a parameter when you bind a value in the VALUES clause of INSERT statement or in the WHERE clause. Note that it is allowed to bind a value to a MARK(?) by using the cubrid_bind(3) function only. PARAMETERS
o $conn_identifier -Connection identifier. o $prepare_stmt -Prepare query. o $option -OID return option CUBRID_INCLUDE_OID. RETURN VALUES
Request identifier, if process is successful; FALSE, if process is unsuccessful. EXAMPLES
Example #1 cubrid_prepare(3) example <?php $conn = cubrid_connect("localhost", 33000, "demodb"); $sql = <<<EOD SELECT g.event_code, e.name FROM game g JOIN event e ON g.event_code=e.code WHERE host_year = ? AND event_code NOT IN (SELECT event_code FROM game WHERE host_year=?) GROUP BY event_code; EOD; $req = cubrid_prepare($conn, $sql); cubrid_bind($req, 1, 2004); cubrid_bind($req, 2, 2000); cubrid_execute($req); $row_num = cubrid_num_rows($req); printf("There are %d event that exits in 2004 olympic but not in 2000. For example: ", $row_num); printf("%-15s %s ", "Event_code", "Event_name"); printf("---------------------------- "); $row = cubrid_fetch_assoc($req); printf("%-15d %s ", $row["event_code"], $row["name"]); $row = cubrid_fetch_assoc($req); printf("%-15d %s ", $row["event_code"], $row["name"]); cubrid_disconnect($conn); ?> The above example will output: There are 27 event that exits in 2004 olympic but not in 2000. For example: Event_code Event_name ---------------------------- 20063 +91kg 20070 64kg SEE ALSO
cubrid_execute(3), cubrid_bind(3). PHP Documentation Group CUBRID_PREPARE(3)
All times are GMT -4. The time now is 12:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy