If your first data line always starts with a date e.g.
then you can search this line and print up to the end.
Or without GNU sed, the poor man approach
okay that worked, sorry i was looking at wrong file i guess. didnt realized that it created a new file....
is there a way to do the same without creating a new file ?...just use the same file and also could you please explain what exactly is the below doing ?
'/headers/{p=1;next}p'
If the string headers is found then set variable p to 1 and proceed with the next cycle (line).
If p is not zero (or unset) then print the line (default action).
By switching the order one can save the next:
Or
Or ---------- Post updated at 05:00 PM ---------- Previous update was at 04:36 PM ----------
Quote:
Originally Posted by crazy_max
the below seem to work...could you please explain what you are doing ?
ls -tr file* |
while read f
do
sed -i -n '\m^ *[0-9]\{1,2\}/[0-9]\{1,2\}/[0-9]\{4\}m,$ p' "$f"
done
processes the oldest files first, like in your initial post.
The file loop is an alternative to a for loop.
sed: -i in place replacement -n noprint mode, so it needs explicit printing. /search/,$ p from the line where search is found thru the $=last line print. search is a RE (regular expression), here ^ *[0-9]\{1,2\}/[0-9]\{1,2\}/[0-9]\{4\}. Because the expression contains a / that collides with the / delimiter, I have replaced the delimiters to another character m that is not in the RE\msearchm.
The RE means: beginning of line, optional spaces, a digit 1 or 2 times, a /, a digit 1 or 2 times, a /, a digit 4 times.
Bootstrap is great; but we have had some issues with Bootstrapped <tables> (and legacy <fieldset> elements) showing annoying, wayward lines. I solved that problem today with this simple jQuery in the footer:
<script>
$(function(){
$('tr, td, fieldset,... (0 Replies)
Hi
I have a scenario:
I have a directory say DIR1 (no sub directories) and have few files in that directory as given below:
app-cnd-imp-20150820.txt
app-cxyzm-imp-20150820.txt
app-petco-imp-20150820.txt
app-mobility-imp-20150820.txt
app-mobility-imp-20150821.txt... (7 Replies)
Dear all,
I have a file like this:
imput
scaffold_0 1
scaffold_0 10000
scaffold_0 20000
scaffold_0 25000
scaffold_1 1
scaffold_1 10000
scaffold_1 20000
scaffold_1 23283
and I want the output like this:
scaffold_0 1 scaffold_0 10000
scaffold_0 10000 scaffold_0 20000... (6 Replies)
Hello
I'd like to remove any line in an output file that is preceded by one or more warning messages (each warning is on a separate line).
Example :
WARNING: Estimation of lower confidence limit of \rho failed; setting it to 0.
822 28447 ... (4 Replies)
Hi,
I have a file with header, detail and trailer records.
HDR|111
DTL|abc|100|xyz
DTL|abc|50|xyz
TRL|150
I need to add the values in 3rd field from DTL records.
Using awk, I am doing it as follows:
awk -F'|' '$1=="DTL"{a += $3} END {print a}' <source_file>
However, I want to... (3 Replies)
Hi
I am trying to write a small AWK program to extract 324 lines which have a pattern in the line numbers.
For examples, I want to extract lines 2, 5, 7, 11 and lines like (2+662), (5+662), (7+662), (11+662) and (2+662+662), (5+662+662), (7+662+662), (11+662+662) and so on for 27 times from... (5 Replies)
I've done this before but I can't remember how. Too long away from vi.
I want to do a search are replace, but I want the replace to be a join.
Example
see spot run
see spot walk
see spot run fast
see spot hop
%s/run$/<somehow perform a join with the next line>/g
so the results... (0 Replies)
I have an application that executes, printing a bunch of text to the screen... only problem is that I don't want to see the first line (the internal command being run) or the last line (it says "done")
is there something to chop off the first and last line simply through use of piping the... (2 Replies)