Here is another way to do what rdrtx1 was doing just using awk to create two output files and cp to copy the updated version of the input file back to the input file when it is done. Of course, both of these suggestions depend on entries in your input files always being in increasing time order (as in your sample data):
This was written and tested using a Korn shell, but this should work with any shell that uses basic Bourne shell syntax (including ash. bash, dash, ksh, zsh, and several others; but not csh and its derivatives).
If you want to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk or nawk.
Hi, I have a csv file with a key composed by 3 columns and some other numeric fields and I need to obtain the partial amounts by some part of the key. This may be some difficult to understand, so better see an example, where my input file is:
name,surname,department,y2004,y2005,y2006... (6 Replies)
All,
I have the following format of data in a spreadsheet
A 1
2
3
4
B 1
2
3
4
where 'A' is value of 'A1', '1 2 3 4' is value of cell B1, 'B' is value of cell A2, and '1 2 3 4' is value of cell B2.
There... (12 Replies)
Hi Guyz
The 1st column of the input file has repeated keys like x,y and z.
The ist task is if the 1st column has unique key (say x) and then need to consider 4th column, if it is + symbol then subtract 2nd column value with 3rd column value (we will get 2(10-8)) or if it is - symbol subtract 3rd... (3 Replies)
hello everyone,
well I have a file which contains data, I want to add the data on hourly basis, like my file contains data for 24 hours, (so a total of 1440 ) lines.
Now i want to add the data on hourly basis to get average values.
like if I use (head) command it is ok for first go, but... (5 Replies)
Dear Friends,
I have an input file contains lot of datas, which is like repaeated rows report.
The output file need to have column wise report, rather than row-wise.
Input File
random line 1
random line 2
random line 3
-------------------------------------
Start line 1.1 (9.9) ... (1 Reply)
Hello,
I would like to remove the first column of lines beginning by a character (in my case is an open square bracket) and finishing by a space (or any other delimiter).
For example:
string1 string2 string3
to
string2 string3
I found this previous topic:
... (1 Reply)
Hello Unix Gurus,
I have a request 2 perform several functions on a file, delete columns, delete rows based on column value, and finally move around columns in the final output. Consider the following input file with 12 columns;
... (1 Reply)
I have 1000s of these rows that I would like to transpose to columns. However I would like the transpose every 3 consecutive rows to columns like below, sorted by column 3 and provide a total for each occurrences. Finally I would like a grand total of column 3.
21|FE|41|0B
50\65\78
15... (2 Replies)
Hello,
I have two files to be treated.
First file:
col1 col2 col3 col4
Second file:
colbis
- I try to add the unique column of the file 2 towards the file 1.
- To obtain the following result with a shell script ksh:
col1 col2 col3 col4 colbis (4 Replies)
Discussion started by: khalidou13
4 Replies
LEARN ABOUT PLAN9
grep
GREP(1) General Commands Manual GREP(1)NAME
grep - search a file for a pattern
SYNOPSIS
grep [ option ... ] pattern [ file ... ]
DESCRIPTION
Grep searches the input files (standard input default) for lines (with newlines excluded) that match the pattern, a regular expression as
defined in regexp(6). Normally, each line matching the pattern is `selected', and each selected line is copied to the standard output.
The options are
-c Print only a count of matching lines.
-h Do not print file name tags (headers) with output lines.
-i Ignore alphabetic case distinctions. The implementation folds into lower case all letters in the pattern and input before interpre-
tation. Matched lines are printed in their original form.
-l (ell) Print the names of files with selected lines; don't print the lines.
-L Print the names of files with no selected lines; the converse of -l.
-n Mark each printed line with its line number counted in its file.
-s Produce no output, but return status.
-v Reverse: print lines that do not match the pattern.
Output lines are tagged by file name when there is more than one input file. (To force this tagging, include /dev/null as a file name
argument.)
Care should be taken when using the shell metacharacters $*[^|()= and newline in pattern; it is safest to enclose the entire expression in
single quotes '...'.
SOURCE
/sys/src/cmd/grep.c
SEE ALSO ed(1), awk(1), sed(1), sam(1), regexp(6)DIAGNOSTICS
Exit status is null if any lines are selected, or non-null when no lines are selected or an error occurs.
GREP(1)