06-19-2009
For example:
2345
4567
8910
TOTAL 1234
......
3456
7890
1234
TOTAL 5678
.....
In a file, there are many lines with "TOTAL" on it. I want to find "TOTAL" on that file and copy the next string after that on that certain line. Afterwards, paste that other string a new file.
Actualy, i haven't tried anythng yet. I don't know where to start. Tnx!
---------- Post updated at 01:14 PM ---------- Previous update was at 01:12 PM ----------
And there is no fixed interval on the occurence of the "TOTAL"s lines. Thanks!
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hello there
I need to find a string in an file, and then copy to a new file from the previous 6 lines to 41 lines after the string.
So, what i need to do , and just don't know how, is to find the string and copy 48 lines where the string would be in the 7th line.
I don't know if i can do it with... (10 Replies)
Discussion started by: vascobrito
10 Replies
2. UNIX for Dummies Questions & Answers
HI
In my script, i am reading the input from the user and want to find the length of the string.
The input may contain leading spaces. Right now, when leading spaces are there, they are not counted.
Kindly help me
My script is like below. I am using the ksh.
#!/usr/bin/ksh
echo... (2 Replies)
Discussion started by: dayamatrix
2 Replies
3. Shell Programming and Scripting
I have a textfile containing text similar to the following pattern:
STRING1
UNIQUE_STRING1
STRING2
STRING3
STRING4
STRING5
STRING1
UNIQUE_STRING2
STRING2
STRING3
STRING4
STRING5
STRING1
UNIQUE_STRING3
STRING2
STRING3 (6 Replies)
Discussion started by: ilcsfe
6 Replies
4. Shell Programming and Scripting
What's the easiest way to search a file for a specific string and then look for other instances after that? I want to search for all Virtual Hosts and print out the Server Name and Document Root (if it has that info), while discarding the rest of the info.
Basically my file looks like this:
...... (6 Replies)
Discussion started by: Mbohmer
6 Replies
5. Shell Programming and Scripting
i have a file1 with many lines. i have a script that will let me input a string. for example, APPLE. what i need to do is to copy all lines from file1 where i can find APPLE or any string that i specify and paste in on file 2
thanks in advance! (4 Replies)
Discussion started by: engr.jay
4 Replies
6. Linux
Hi all,
I have a question..
Here is my requirement..I have 500 files in a path say /a/b/c
I have some numbers in a file which are comma seperated...and I wanted to check if the numbers are present in the FileName in the path /a/b/c..if the number is there in the file that is fine..but if... (1 Reply)
Discussion started by: us_pokiri
1 Replies
7. Shell Programming and Scripting
I am new, really new to bash scripts.
I want to search an XML file for a certain string, say "1234567890"
Once found, I want to copy the entire contents from the previous instance of the string "Entity" to the next instance of "/Entity" to a txt file.
And then continue searching for the... (4 Replies)
Discussion started by: jrfiol
4 Replies
8. Shell Programming and Scripting
Hi All,
I am new to shell srcipting.
Problem :
I need to write a script which copy the log files from /prod/logs directory based on todays date like (Jul 17) and place it to /home/hzjnr0 directory and then search the copied logfiles for the string "@ending successfully on Thu Jul 17". If... (2 Replies)
Discussion started by: mail.chiranjit
2 Replies
9. Shell Programming and Scripting
Hi,
Here's my dilemma.
I need to replace the string Sept_2012 to Oct_2012 in all *config.py files within the current directory and below directories
Is this possible?
Also I am trying to find all instances of the string Sept_2012 within files in the current directory and below
I have... (13 Replies)
Discussion started by: pure_jax
13 Replies
10. Shell Programming and Scripting
Hi,
I did some research but cannot find the right solution so hopefully someone can help me here.
I have a long string format like:
VAR=111:aaaa,222:bbb,333:ccc
it could be
VAR=111:aaa,222:bbb,333:ccc,444:ddd, etc
what I looking for is eg.
if I give ccc, it will return me 333... (2 Replies)
Discussion started by: netbanker
2 Replies
TOTAL(1) General Commands Manual TOTAL(1)
NAME
total - sum up columns
SYNOPSIS
total [ -m ][ -sE | -p | -u | -l ][ -i{f|d}[N] ][ -o{f|d} ][ -tC ][ -N [ -r ]] [ file .. ]
DESCRIPTION
Total sums up columns of real numbers from one or more files and prints out the result on its standard output.
By default, total computes the straigt sum of each input column, but multiplication can be specified instead with the -p option. Likewise,
the -u option means find the upper limit (maximum), and -l means find the lower limit (minimum).
Sums of powers can be computed by giving an exponent with the -s option. (Note that there is no space between the -s and the exponent.)
This exponent can be any real number, positive or negative. The absolute value of the input is always taken before the power is computed
in order to avoid complex results. Thus, -s1 will produce a sum of absolute values. The default power (zero) is interpreted as a straight
sum without taking absolute values.
The -m option can be used to compute the mean rather than the total. For sums, the arithmetic mean is computed. For products, the geomet-
ric mean is computed. (A logarithmic sum of absolute values is used to avoid overflow, and zero values are silently ignored.)
If the input data is binary, the -id or -if option may be given for 64-bit double or 32-bit float values, respectively. Either option may
be followed immediately by an optional count, which defaults to 1, indicating the number of double or float binary values to read per
record on the input file. (There can be no space between the option and this count.) Similarly, the -od and -of options specify binary
double or float output, respectively. These options do not need a count, as this will be determined by the number of input channels.
A count can be given as the number of lines to read before computing a result. Normally, total reads each file to its end before producing
its result, but this behavior may be overridden by inserting blank lines in the input. For each blank input line, total produces a result
as if the end-of-file had been reached. If two blank lines immediately follow each other, total closes the file and proceeds to the next
one (after reporting the result). The -N option (where N is a decimal integer) tells total to produce a result and reset the calculation
after every N input lines. In addition, the -r option can be specified to override reinitialization and thus give a running total every N
lines (or every blank line). If the end of file is reached, the current total is printed and the calculation is reset before the next file
(with or without the -r option).
The -tC option can be used to specify the input and output tab character. The default tab character is TAB.
If no files are given, the standard input is read.
EXAMPLE
To compute the RMS value of colon-separated columns in a file:
total -t: -m -s2 input
To produce a running product of values from a file:
total -p -1 -r input
BUGS
If the input files have varying numbers of columns, mean values will certainly be off. Total will ignore missing column entries if the tab
separator is a non-white character, but cannot tell where a missing column should have been if the tab character is white.
AUTHOR
Greg Ward
SEE ALSO
cnt(1), neaten(1), rcalc(1), rlam(1), tabfunc(1)
RADIANCE
2/3/95 TOTAL(1)