Sponsored Content
Full Discussion: Delta from the first digit
Top Forums Shell Programming and Scripting Delta from the first digit Post 302986792 by Board27 on Wednesday 30th of November 2016 08:46:30 AM
Old 11-30-2016
Delta from the first digit

Thanks of your suggestions i was able to calculate the delta between some numbers in a column file with .

Code:
 awk 'BEGIN{last=0}{delta[NR]=$1-last; last=$1; print $0" "delta[NR]}'

the file was like

Code:
499849120.00
500201312.00
500352416.00
500402784.00
500150944.00
499849120.00
500150944.00
500453184.00
499949664.00
500050304.00
500100640.00

but what if i want to use the first element of this list and create the delta between the first element on the list and all the others?

Thanks in advance.

Best regards
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

why "expr "${REPLY}" : '\([1-9][[:digit:]]*\)" can figure out whether it is a digit?

I found below script to check whether the variable is a digit in ksh. ############################ #!/bin/ksh REPLY="3f" if ]*\)'` != ${REPLY} && "${REPLY}" != "0" ]] then print "is digit\n" else print "not digit\n" fi ############################ Although it works fine, but... (6 Replies)
Discussion started by: sleepy_11
6 Replies

2. Shell Programming and Scripting

Replace one digit by two digit using sed

Folks, Is there a simple way to replace one digit by two digit using sed. Example, mydigit1918_2006_8_8_lag1.csv should be mydigit1918_2006_08_08_lag01.csv. I tried this way, but doesn't work. echo mydigit1989_2006_8_8_lag1.csv|sed 's/]/0]/' Thank you, (5 Replies)
Discussion started by: Jae
5 Replies

3. Shell Programming and Scripting

How to convert a 2 digit to 4 digit

Hi All, How can i convert a number 24 to 0024 In the same way how can i convert 123 to 0123? All this has to be done inside a script Thanks in advance JS (6 Replies)
Discussion started by: jisha
6 Replies

4. Shell Programming and Scripting

Single digit date to double digit date.

I have a var storing date var=`date` Now the date is returned as Mon Feb 2 00:25:48 PST 2009 Is there any way to check the date field alone ("2" in above case) and if its a single digit then add a prefix 0 to it and store the result in same variable "var" My intention in above case is... (3 Replies)
Discussion started by: villain41
3 Replies

5. Shell Programming and Scripting

Creating DELTA file in UNIX

I have a fixed length file (854 characters file). Our project will start getting this file soon. On the first day this file will have 100000 records. From the next day the file will have all the records from previous day + some new records (there will be few additions + few changes in day1... (13 Replies)
Discussion started by: varunrbs
13 Replies

6. Shell Programming and Scripting

awk length of digit and print at most right digit

Have columns with digits and strings like: input.txt 3840 3841 3842 Dav Thun Tax Cahn 146; Dav. 3855 3853 3861 3862 Dav Thun Tax 2780 Karl VI., 3873 3872 3872 Dav Thun Tax 3894 3893 3897 3899 Dav Thun Tax 403; Thun 282. 3958 3959 3960 Dav Thun Tax 3972 3972 3972 3975 Dav Thun Tax... (8 Replies)
Discussion started by: sdf
8 Replies

7. Shell Programming and Scripting

convert two digit in to single digit...

Hi Guys. My Input: ABCD 12 00 KL ABCD 12 08 DL ABCD 12 10 KK ABCD 12 04 LL ABCD 13 00 LP ABCD 13 1O LS Output: ABCD 12 0 KL ABCD 12 8 DL ABCD 12 10 KK ABCD 12 4 LL ABCD 13 0 LP (2 Replies)
Discussion started by: pareshkp
2 Replies

8. Shell Programming and Scripting

File delta detection

Hello, I need to compare two flat files (ASCII format), say file OLD and file NEW. Both have similar structure. These files are | delimitted files and have around few million of records (lines) each. Each file has same set columns and same set of key columns (i.e. the 3rd and 5th column of the... (7 Replies)
Discussion started by: manubatham20
7 Replies

9. Shell Programming and Scripting

GPS extracts fix delta time

Hello all, I am currently trying to find the delta time from some GPS log. I am using the following script with awk. But the script result shows some incorrect values (delta time some time = 0.2 but when I check it manually it is equal to 0.1) My final goal is to get a script that print... (7 Replies)
Discussion started by: redafenj
7 Replies
prs(1)							      General Commands Manual							    prs(1)

NAME
prs - print and summarize an SCCS file SYNOPSIS
dataspec] [SID]] cutoff] file ... DESCRIPTION
The command prints, on the standard output, parts or all of an SCCS file (see sccsfile(4)) in a user-supplied format. If a directory is named, behaves as though each file in the directory were specified as a named file, except that non-SCCS files (last component of the path name does not begin with and unreadable files are silently ignored. If a name of is given, the standard input is read; each line of the standard input is taken to be the name of an SCCS file or directory to be processed; non-SCCS files and unreadable files are silently ignored. A on the command line implies that all following arguments are file/directory names. Arguments to which can appear in any order, consist of options and file names. Options All of the described options apply independently to each named file: Used to specify the output data specification. dataspec is a string consisting of SCCS file data keywords (see Data Keywords below) interspersed with optional user- supplied text. Used to specify the SCCS IDentification (SID) string of a delta for which information is desired. If no SID is specified, the SID of the most recently created delta is assumed. If an SID is specified, it must agree exactly with an SID in the file (that is, the SID structure used by does not work here -- see get(1)). Requests information for all deltas created than and including the delta designated via the option or the date given by the option. Requests information for all deltas created than and including the delta designated via the option or the date given by the option. Cutoff date-time, in the form YY[MM[DD[HH[MM[SS]]]]] Units omitted from the date-time default to their maximum possible values. Thus, is equivalent to One or more non- numeric characters can be used to separate the various 2-digit segments of the cutoff date (for example For 2-digit year input the following interpretation is taken: Requests printing of information for both removed, that is, delta type = R, (see rmdel(1)) and existing, that is, delta type = D, deltas. If the option is not speci- fied, information is provided for existing deltas only. If no option letters (or only are given, prints the file name using the default dataspec and the option. This produces information on all deltas. Data Keywords Data keywords specify which parts of an SCCS file are to be retrieved and output. All parts of an SCCS file (see sccsfile(4)) have an associated data keyword. There is no limit on the number of times a data keyword can appear in a dataspec. The information printed by consists of: (1) the user-supplied text; and (2) appropriate values (extracted from the SCCS file) substituted for the recognized data keywords in the order of appearance in the dataspec. The format of a data keyword value is either (S), in which keyword substitution is direct, or (M), in which keyword substitution is followed by a carriage return. User-supplied text is any text other than recognized data keywords. Escapes can be used as follows: backslash \ form feed f backspace  new-line carriage return single quote ' colon : tab The default dataspec is: SCCS File Data Keywords File Keyword Data Item Section Value Fmt ------------------------------------------------------------------------------- :Dt: Delta information Delta Table See below* S :DL: Delta line statistics " :Li:/:Ld:/:Lu: S :Li: Lines inserted by Delta " nnnnn S :Ld: Lines deleted by Delta " nnnnn S :Lu: Lines unchanged by Delta " nnnnn S :DT: Delta type " D or R S :I: SCCS ID string (SID) " :R:.:L:.:B:.:S: S :R: Release number " nnnn S :L: Level number " nnnn S :B: Branch number " nnnn S :S: Sequence number " nnnn S :D: Date Delta created " :Dy:/:Dm:/:Dd: S :Dy: Year Delta created " nn S :Dm: Month Delta created " nn S :Dd: Day Delta created " nn S :T: Time Delta created " :Th:::Tm:::Ts: S :Th: Hour Delta created " nn S :Tm: Minutes Delta created " nn S :Ts: Seconds Delta created " nn S :P: Programmer who created Delta " logname S :DS: Delta sequence number " nnnn S :DP: Predecessor Delta seq-no. " nnnn S :DI: Seq # of deltas incl, excl, " :Dn:/:Dx:/:Dg: S ign :Dn: Deltas included (seq #) " :DS: :DS:... S :Dx: Deltas excluded (seq #) " :DS: :DS:... S :Dg: Deltas ignored (seq #) " :DS: :DS:... S :MR: MR numbers for delta " text M :C: Comments for delta " text M :UN: User names User name text M :FL: Flag list Flags text M :Y: Module type flag " text S :MF: MR validation flag " yes or no S :MP: MR validation pgm name " text S :KF: Keyword error/warning flag " yes or no S :KV: Keyword validation string " text S :BF: Branch flag " yes or no S :J: Joint edit flag " yes or no S :LK: Locked releases " :R:... S :Q: User defined keyword " text S :M: Module name " text S :FB: Floor boundary " :R: S :CB: Ceiling boundary " :R: S :Ds: Default SID " :I: S :ND: Null delta flag " yes or no S :FD: File descriptive text Comments text M :BD: Body Body text M :GB: Gotten body " text M :W: A form of what(1) string N/A :Z::M: :I: S :A: A form of what(1) string N/A :Z::Y: :M: :I::Z: S :Z: what(1) string delimiter N/A @(#) S :F: SCCS file name N/A text S :PN: SCCS file path name N/A text S If no option letters (or only are given, prints the file name, using the default dataspec, and the option; thus, information on all deltas is produced. EXTERNAL INFLUENCES
Environment Variables determines the interpretation of dataspec as single and/or multi-byte characters. determines the language in which messages are displayed. If or is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty variable. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of If any internationalization variable contains an invalid setting, behaves as if all internationalization variables are set to "C". See environ(5). International Code Set Support Single-byte and multi-byte character code sets are supported. DIAGNOSTICS
See sccshelp(1) for explanations. EXAMPLES
The entry may produce on the standard output: The entry may produce on the standard output: As a (when no specifications for selecting or printing are given) may produce on the standard output: for each delta table entry of the "D" type. The only option argument allowed to be used with the is the option. FILES
SEE ALSO
admin(1), delta(1), get(1), sccshelp(1), sccsfile(4). STANDARDS CONFORMANCE
prs(1)
All times are GMT -4. The time now is 06:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy