Sponsored Content
Top Forums Shell Programming and Scripting Taking sum up all values inside the file Post 302666197 by NareshN on Wednesday 4th of July 2012 01:39:33 AM
Old 07-04-2012
Taking sum up all values inside the file

Hi,

Taking sum up all values inside the file by using the below command:

paste -sd+ filenmae | bc

Getting some error like "0705-001: building space exceeded on line1 stdin"

The original data looks like

SPACE SPACE SPACE 0.123 [.\] JOBNAME1
SPACE SPACE 20.325 [.\] JOBNAME2
SPACE SPACE SPACE SPACE SPACE 402.238 [.\] JOBNAME3

Like that, some thousands of records for four files. By using sed command, removing all the starting spaces in a file and storing vlaues(i.e., cpu time) column alone in a file and trying take to the count by using paste command.

I tried to use different scenarios to take the count by using awk, eventhough am getting same error.

The error is displaying for few files only. I verified the file contents there is no spaces or empty rows.

Thanks for you help in advance.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Please help me in taking the values from a file

i have a script, whcih takes values from a file and assign it to one variable. this text value contains name of few object. value contains line by lie. i.e. one after another. when i am assaign the value of this text file to a variable, it accept the value as one liner instead of one by one.... (3 Replies)
Discussion started by: jin
3 Replies

2. Shell Programming and Scripting

How To Sum Values Inside One Line In UNIX.?

Dears, Good Day ! Plz; i want to sum-up two consecutive values inside one row, and put the summation in a new column. here the input: 1 2 4 5 6 7 the output should be: 1 2 3 4 5 9 6 7 13 If someone can help me to solve my issue ! thx anyway. Video tutorial on how to use... (5 Replies)
Discussion started by: Ala Alzyadat
5 Replies

3. Shell Programming and Scripting

Get the sum of values in between begin and end in the file

Hi All, test file Begin Script Run at Thu Mar 14 09:24:16 PDT 2013 tst_accounts: ws zip: WS_out_20130313.tar.gz dat: test_20130313.dat count: 63574 loaded: xx pre-merge: xx post-merge: xx timestamp: Thu Mar 14 09:30:42 PDT 2013 tst_accounts: ws zip: WS_out_20130313.tar.gz dat: s_20130313.dat... (6 Replies)
Discussion started by: bmk
6 Replies

4. Shell Programming and Scripting

How to find sum of any 'n' number of values from file matching target value?

I have a simple text file having payment amount value on each line. At the end of day 'n' number of payments created difference in amount that I need to match from this file. I have information about how many payments created difference and difference amount. Please help me to build shell... (3 Replies)
Discussion started by: swats007
3 Replies

5. Shell Programming and Scripting

Sum values of specific column in multiple files, considering ranges defined in another file

I have a file (let say file B) like this: File B: A1 3 5 A1 7 9 A2 2 5 A3 1 3 The first column defines a filename and the other two define a range in that specific file. In the same directory, I have also three more files (File A1, A2 and A3). Here is 10 sample lines... (3 Replies)
Discussion started by: Bastami
3 Replies

6. Shell Programming and Scripting

SUM semicolon-seperated values from txt-file

Hello, (I'm a shell beginner) how can I sum the bold values of the following txt-file (values.txt) with bash shell. The result of the sum should be written in a new txt file (sum.txt): ... Thanks in advance (5 Replies)
Discussion started by: milu
5 Replies

7. Shell Programming and Scripting

Sum duplicate values in text file through awk between dates

I need to sum values in text file in case duplicate row are present with same name and different value below is example of data in file i have and format i need. Data in text file 20170308 PM,U,2 PM,U,113 PM,I,123 DA,U,135 DA,I,113 DA,I,1 20170309 PM,U,2 PM,U,1 PM,I,123 PM,I,1... (3 Replies)
Discussion started by: Adfire
3 Replies

8. Shell Programming and Scripting

Taking key values from one file and extracting values from another file

Hi, I have two files with values in both. File1: cat 2 3 dog 4 5 elephant 6 7 camel 2 3 File2: ----+--gkf;ajf= ---+---- +----- cat -------=----+ 3 | 4 ----- dog ------++-- 5 | 9 ----++-- elephant | 5 | 7 ---++ camel ------ ++++_---- || 8 | 9 I want the final file as: cat 4... (1 Reply)
Discussion started by: npatwardhan
1 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 Beginners Questions & Answers

Replacing values inside a file.

Good day guys, I'm having trouble in creating a logic when it comes to replacing the values inside a file. I tried using sed command but it just doesn't work the way I want it to be. Here is what I'm trying to achieve. If my input file contains the values below. NAME++GUEST1 ++GUESS2++... (3 Replies)
Discussion started by: asdfghjkl
3 Replies
kitcap(5)							File Formats Manual							 kitcap(5)

Name
       kitcap - kit descriptor database for gentape and genra utilities.

Description
       The  file is a database for kit descriptors containing product codes, directories, files, and subsets that make up a product description to
       be used by or to create distribution media.  All fields are separated by colons (:) with a backslash () at the end of  a  line	indicating
       continuation.   Lines  starting	with a number sign (#) are considered comments and are ignored.  Comment fields with a kitcode description
       are delimited by an opening number sign (#) and a closing colon (:).

       The following entry examples are for TK50 and MT9 media types:
       Product-codeTK | Product Description:directory1:directory2:directory3:
	    SPACE:SPACE:SPACE:INSTCTRL:subset1:subset2:subset3:subset4:subset5

       Product-codeMT | Product Description:directory1:directory2:directory3:
	    SPACE:SPACE:SPACE:INSTCTRL:subset1:subset2:subset3:subset4:subset5:
	    %%2:
	    subset6:subset7:subset8:subset9:subset10

       The following parts make up the descriptor for magnetic tape media:

       Product-code
	      This is an arbitrary name made up of letters and/or numbers unique to the product that it describes.  Typical codes include a  prod-
	      uct identifier and a version identifier, as indicated in the previous examples.

       Media-code (TK or MT)
	      The media-code is a 2 letter reference that describes the type of media the files will be written to.  The media code must be either
	      TK for TK50 or MT for 9-track magnetic tape devices.  During run time, the utility probes the device to be written to and determines
	      if  it is a TK50- or MT9-type device.  It then appends either TK or MT to the kitcode given on the command line and searches for the
	      kitcode (product-code/media-code) in the kitcap file.

       Product Description
	      This field is a description of the software product that is being created by the utility and replaces the NAME field in the file	of
	      all the subsets that make up a product.  This is an optional field for magnetic tape media.

       Directories
	      The magnetic tape media production utility has the ability of producing multi-product tapes.  That is, it can take subsets from dif-
	      ferent products that are based in different directories and merge them together to form a third product, which is a  combination	of
	      the  original  products.	Directory entries provide the full path locations of where the subsets that are to be put on media will be
	      stored.  There must be at least one directory entry for each kitcap descriptor.

       SPACE
	      The SPACE file is a place holder for tape records composed of 1k of NULL characters. Three SPACE files are used as  dummy  files	to
	      ensure compatibility with ULTRIX operating system kits.

       INSTCTRL
	      The INSTCTRL image contains setld control information.

       Subsets
	      This  field  provides  a list of subsets or files that are to be either written to the magnetic tape media or verified from the mag-
	      netic tape media.  Each subset listed must be stored in one of the directories listed in that particular kitcap  descriptor.   If  a
	      file or subset is stored in a subdirectory of one of the directories listed in the kitcap descriptor, it is possible to include that
	      sub-path with the subset/filename entry instead of listing the entire path/subpath as another directory  listing.   For  example,  a
	      directory listed in the kitcap descriptor under the rules given in the Directories section is listed as:
	      /KITS/MYPRODUCT/001
	      A particular subset or file that a user would like to include on the media is stored in:
	      /KITS/MYPRODUCT/001/subdirectory/subset
	      Since the subdirectory/subset specification is part of the directory tree, it is not necessary to include the full path subdirectory
	      in the directory listing.  An alternative is to include the subdirectory path with the subset name in the subset list.  For example:
	      MY-PROD-001 | This is a good product:
		   /KITS/MYPRODUCT/001:SPACE:SPACE:SPACE:
		   INSTCTRL:subset1:subset2:subdirectory/subset3:subset4

       Volume identifier (MT9 media only)
	      The volume identifier is optional.  Multi-tape support is available for products that have subsets or files that take up	more  room
	      than is available by a single 9-track magnetic tape.  If the subset list results in an end-of-tape condition, the subset list can be
	      split into any number of multi-volume sets by placing (where n is the volume number of the next tape) anywhere  appropriate  in  the
	      subset  list.   The  subsets listed between the volume identifiers must fit on a single piece of media.  By default, the subset list
	      located directly after the directory list is always considered the first volume.	Therefore, a volume identifier for the first  vol-
	      ume in a multi-volume kit descriptor is not necessary.

       The following example shows a entry for disks:
       Product-codeRA:partition:
	    dd=/:Product_Description:
	    directory1:directory2:directory3:
	    instctrl:subset1:subset2:subset3:subset4:subset5:
	    dd=SUB/DIR:Product_Description:
	    instctrl:directory1:directory2:directory3:
	    subset1:subset2:subset3:subset4:subset5

       The following parts make up the kitcap descriptor for disk media:

       Product-code
	      Same as for magnetic tape.

       Media-code
	      The media code for disks is RA and is appended to the product-code provided by the user at run time, by the utility.

       Disk Partition
	      This field is the partition where you want the software written to on the disk.

       dd=
	      This  field  tells the utility what directory you want the subsets written to on the disk media that is being created.  The contrac-
	      tion can be thought of as the ``destination directory'' for the subsets.	This field is required and allows a hierarchial  structure
	      for  those  who want to put multiple products on the same disk, or want to separate parts of one product into different areas on the
	      disk.

       Typically, a disk is mounted by the utility onto a temporary mount point under This location becomes the disks root directory.  If  a  user
       wants to have only one directory for an entire product, a valid entry would be dd=/.  This entry tells the utility to write all the follow-
       ing subsets under the mount point.

       In the disk kitcap descriptor example given previously, the first five subsets are being written to the mount point, or root directory, for
       the  disk  media  being made.  Then a new directory on the disk media is made, and the next five subsets are written into that directory on
       the disk media.

       It is important to note that the top-level directory of the media disk is always considered the mount point used by the script and is  ref-
       erenced	by dd=/.  Any subdirectories listed as destination directories are created starting from the mount point and must be referenced in
       full.  For instance, in the previous example, if the user wanted to put some other subsets in a subdirectory of DIR,  the  entry  would	be
       dd=SUB/DIR/SUBSUBDIR.  Note that each new destination directory requires a product description.

       Product Description
	      This field is similar to the one defined under the magnetic tape description.  However, in the case of disk media there are 2 impor-
	      tant differences.  The product description is a required field, and all words in the description must be connected with  underscores
	      (_).  The script removes the underscores at run time.  For example, suppose the desired description was as follows:
	      This is a good product
	      The Product Description entry when making disk media would become:
	      This_is_a_good_product

       Directories
	      Same as for magnetic tape.

       instctrl
	      A directory containing the same information as INSTCTRL for magnetic tape.

       Subsets
	      Same as for magnetic tape.

Examples
       TK50 and MT9 (single-volume tape)kitcap description
       MYPRODUCT400 | MYPRODUCT software version 4:
	    :# directory listing :
	    /directory1:/directory2:/directory3:
	    SPACE:SPACE:SPACE:INSTCTRL:
	    :# subset listing :
	    subset1:subset2:subset3:subset4:subset5

       MT9 kitcap description (multi-volume tape)
       MYPRODUCT400 | MYPRODUCT software version 4:
	    /directory1:/directory2:/directory3:
	    SPACE:SPACE:SPACE:INSTCTRL:
	    subset1:subset2:subset3:subset4:subset5:
	    :# Volume 2 :
	    %%2:
	    subset6:subset7:subset8:subset9:subset10

       RA60 kitcap description (single product)
       MYPRODUCT400:c:
	    dd=/:MYPRODUCT_software_version_4:
	    /directory1:/directory2:/directory3:
	    instctrl:subset1:subset2:subset3:subset4:subset5

       RA60 kitcap description (multiple product)
       MYPRODUCT400:c:
	    dd=MYPRODUCT/BASE:
	    MYPRODUCT_software_version_4_base_subsets:
	    /directory1:/directory2:/directory3:
	    instctrl:subset1:subset2:subset3:subset4:subset5:
	    dd=MYPRODUCT/NONBASE:
	    MYPRODUCT_software_version_4_nonbase_subsets:
	    /directory1:/directory2:/directory3:
	    instctrl:subset1:subset2:subset3:subset4:subset5

See Also
       genra(8), gentapes(8)

																	 kitcap(5)
All times are GMT -4. The time now is 04:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy