Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Add values to file in 2 new columns Post 303044450 by jiam912 on Friday 21st of February 2020 01:34:56 PM
Old 02-21-2020
Hi RudiC.
Thanks a lot for the answer..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to flip values of two columns and add an extra column

Hi guys, Couldn't find the solution of this problem. Please Help! I have a file- Input_File TC200232 92 30 TC215306 2 74 TC210135 42 14 I want an output file in which if column2>column3, the values are swapped and an additional column with value Rev_Com is... (4 Replies)
Discussion started by: smriti_shridhar
4 Replies

2. UNIX for Dummies Questions & Answers

combine the values from the first two columns within a file

Hello everybody, I have a text file containing 10,000 rows and 5000 columns. The values are separated by a tab. Ex. file_ex.ped 1 mike 0 0 2 1 A A G G C T A G 1 jack 0 0 2 2 T A G T C A A C 1 Mary 0 0 1 2 A T G C A T G C ... I would like a out put file 1 mike 0 0 2 1 AA GG CT AG 1... (7 Replies)
Discussion started by: Unilearn
7 Replies

3. Shell Programming and Scripting

Math operations with file columns values.

Hello everybody, I have some large files containing statistical data. The data is stored in the following generic format: >cat my_file 1, 2, 3 1, 2, 3 1, 2, 3 > The values of columns no.2 and 3 are expressed in bytes. I would like to transform them in Megabytes, by dividing them with... (3 Replies)
Discussion started by: fabian23
3 Replies

4. Shell Programming and Scripting

Copy values from columns matching in those in second file.

Hi All, I have two sets of files. Set 1: 100 text files with extension .txt with names like 1.txt, 2.txt, 3.txt until 100.txt Set 2: One big file with extension .dat The text files have some records in columns like this: 0.7316431 82628 0.7248189 82577 0.7248182 81369 0.7222999... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

5. UNIX for Dummies Questions & Answers

Subtracting values from 2 columns in a file

Hello, I have a file with 5 columns that looks like this: A1BG chr19 + 58863335 58866549 A1BG chr19 - 58858171 58864865 A2LD1 chr13 - 101182417 101186056 A2LD1 chr13 - 101182417 101241046 A2M chr12 - 9220303 9268558 A2ML1 ... (5 Replies)
Discussion started by: wolf_blue
5 Replies

6. UNIX for Dummies Questions & Answers

Removing columns from a text file that do not have any values in second and third columns

I have a text file that has three columns. But at the end of the text file, there are trailing lines that have missing second and third columns: 4 0.04972604 KLHL28 4 0.0497332 CSTB 4 0.04979822 AIF1 4 0.04983331 DECR2 4 0.04990344 KATNB1 4 4 4 4 How can I remove the trailing... (3 Replies)
Discussion started by: evelibertine
3 Replies

7. Shell Programming and Scripting

for uniq entries add values in corresponding columns

Hi, I have a file as listed below.. What I want to get is for each unique value in column 1 the corresponding values in the rest of the columns should be summed up.. AAK1 0 1 0 11 AAK1 0 0 1 1 AAK1 0 0 1 2... (2 Replies)
Discussion started by: Diya123
2 Replies

8. Shell Programming and Scripting

Add the values in second and third columns with group by on first column.

Hi All, I have a pipe seperated file. I need to add the values in second and third columns with group by on first column. MYFILE_28012012_1115|47|173.90 MYFILE_28012012_1115|4|0.00 MYFILE_28012012_1115|6|22.20 MYFILE_28012012_1116|47|173.90 MYFILE_28012012_1116|4|0.00... (3 Replies)
Discussion started by: angshuman
3 Replies

9. Shell Programming and Scripting

Add values in 2 columns and subtract from third

Hi All, I have a file with thousands of lines in the following format, where Field1=First 8 characters Field2-9-16 characters Field3=17-26 characters I need to add Field 1 and Field2 and subtract the result from Field 3. Field3=Field3 - (Field1 + Field2) 0012.00 0010.00 0001576.53... (4 Replies)
Discussion started by: nua7
4 Replies

10. UNIX for Beginners Questions & Answers

Awk: compare values in two columns of the same file

I'm trying to learn awk, but I've hit a roadblock with this problem. I have a hierarchy stored in a file with 3 columns: id name parentID 4 D 2 2 B 1 3 C 1 1 A 5 I need to check if there are any values in column 3 that are not represented anywhere in column 1. I've tried this: awk '{arr;}... (7 Replies)
Discussion started by: kaktus
7 Replies
UPSCLI_GET(3)							    NUT Manual							     UPSCLI_GET(3)

NAME
upscli_get - retrieve data from a UPS SYNOPSIS
#include <upsclient.h> int upscli_get(UPSCONN_t *ups, int numq, const char **query, int *numa, char ***answer) DESCRIPTION
The upscli_get() function takes the pointer ups to a UPSCONN_t state structure, and the pointer query to an array of numq query elements. It builds a properly-formatted request from those elements and transmits it to upsd(8). Upon success, the response will be split into separate components. A pointer to those components will be returned in answer. The number of usable answer components will be returned in numa. USES
This function implements the "GET" command in the protocol. As a result, you can use it to request many different things from the server. Some examples are: o GET NUMLOGINS <ups> o GET UPSDESC <ups> o GET VAR <ups> <var> o GET TYPE <ups> <var> o GET DESC <ups> <var> o GET CMDDESC <ups> <cmd> QUERY FORMATTING
To generate a request for GET NUMLOGINS su700, you would populate query and numq as follows: int numq; const char *query[2]; query[0] = "NUMLOGINS"; query[1] = "su700"; numq = 2; All escaping of special characters and quoting of elements with spaces is handled for you inside this function. ANSWER FORMATTING
The raw response from upsd to the above query would be NUMLOGINS su700 1. Since this is split up for you, the values work out like this: numa = 3; answer[0] = "NUMLOGINS" answer[1] = "su700" answer[2] = "1" Notice that the value which you seek typically starts at answer[numq]. ERROR CHECKING
This function will check your query against the response from upsd(8). For example, if you send "VAR" "su700" "ups.status", it will expect to see those at the beginning of the response. If the results from upsd do not pass this case-insensitive test against your request, this function will return an error. When this happens, upscli_upserror(3) will return UPSCLI_ERR_PROTOCOL. ANSWER ARRAY LIFETIME
The pointers contained within the answer array are only valid until the next call to a upsclient function which references them. If you need to use data from multiple calls, you must copy it somewhere else first. The answer array and its elements may change locations, so you must not rely on previous addresses. You must only use the addresses which were returned by the most recent call. You also must not attempt to use more than numa elements in answer. Such behavior is undefined, and may yield bogus data or a crash. The array will be deleted after calling upscli_disconnect(3). Any access after that point is also undefined. RETURN VALUE
The upscli_get() function returns 0 on success, or -1 if an error occurs. SEE ALSO
upscli_list_start(3), upscli_list_next(3), upscli_strerror(3), upscli_upserror(3) Network UPS Tools 05/22/2012 UPSCLI_GET(3)
All times are GMT -4. The time now is 09:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy