Sponsored Content
Top Forums Shell Programming and Scripting Find between lines start and end: awk with bash variables Post 302954088 by RudiC on Friday 4th of September 2015 05:22:27 AM
Old 09-04-2015
Quote:
Originally Posted by jamie_123
.
.
.
The same statements work for other start and end values, but not for 0 and 1056.
. . .
That's because there's many "0"s in them there numbers, so the range immediately starts again (and doesn't get stopped any more). Try to anchor the "0":
Code:
awk -v s="$start" -v e="$end" '$0~"^"s,$0~e' file
0
1056

---------- Post updated at 11:22 ---------- Previous update was at 11:19 ----------

Your file doesn't have 1056 lines. RavinderSingh13's proposal lists until EOF or line 1056, whatever it reaches first.
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

String as both start and end anchors in awk

Not sure if the title of this thread makes sense, but hopefully my explanation will. I'm using awk to print some stats from an apache accesslog. I would like to specify the regexp condition where only the two root pages of "index.html" and "/" are counted in my results. What I can't figure out... (3 Replies)
Discussion started by: picassolsus
3 Replies

2. Shell Programming and Scripting

read a string from its end to its start and stop when you find a specific character

How can I do this? Actually I have a file which contains a path e.g. /home/john/Music/hello.mp3 and I want to take only the filename (hello.mp3) So, I need to read the file from its end to its start till the character "/" Is this possible? Thanks, I am sure you'll not disappoint me here! Oh,... (9 Replies)
Discussion started by: hakermania
9 Replies

3. UNIX for Dummies Questions & Answers

Find Quarter Start and End Dates

Dear Members, Depending on the current date i should find out the start and end dates of the quarter. ex: Today date is 14-Nov-2011 then Quarter start date should be Oct 1 2011 and Quarter End date should be Dec 31 2011. How can i do this? Thanks Sandeep (1 Reply)
Discussion started by: sandeep_1105
1 Replies

4. Shell Programming and Scripting

Fetching a set of lines with start and end

Hi Folks, Need help in fetching a group of lines with a start and end strings. Example is shown below. start#morning tea jog breakfast end start#afternoon lunch work chat end start#evening snacks tea chat (6 Replies)
Discussion started by: jayadanabalan
6 Replies

5. Shell Programming and Scripting

Remove lines between the start string and end string including start and end string Python

Hi, I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
Discussion started by: Dabheeruz
1 Replies

6. Shell Programming and Scripting

awk to count start and end keyword in a line

Hello fellow awkers and seders: need to figure out a way to ensure a software deployment has completed by checking its trace file in which I can store the deployment results as follows: echo $testvar ===== Summary - Deploy Result - Start ===== ===== Summary - Deploy Result - End =====... (1 Reply)
Discussion started by: ux4me
1 Replies

7. Shell Programming and Scripting

Get the lines from logfile within start and end date

Hi guys, I am having the below logfile,date in yyyy-mm-dd 2013-08-02 *some content* 2013-08-02 *some content* 2013-08-02 *some content* 2013-08-03 *some content* 2013-08-05 *some content* from the above logfile i need to get the lines between the two timestamps,if i give... (5 Replies)
Discussion started by: mohanalakshmi
5 Replies

8. Shell Programming and Scripting

awk to remove lines that do not start with digit and combine line or lines

I have been searching and trying to come up with an awk that will perform the following on a converted text file (original is a pdf). 1. Since the first two lines are (begin with) text they are removed 2. if $1 is a number then all text is merged (combined) into one line until the next... (3 Replies)
Discussion started by: cmccabe
3 Replies

9. UNIX for Beginners Questions & Answers

How do delete certain lines alone which are matching with start and end string values in file?

Hi, In my previous post ( How to print lines from a files with specific start and end patterns and pick only the last lines? ), i have got a help to get the last select statement from a file, now i need to remove/exclude the output from main file: Input File format: SELECT ABCD, DEFGH,... (2 Replies)
Discussion started by: nani2019
2 Replies

10. UNIX for Beginners Questions & Answers

How to print lines from a files with specific start and end patterns and pick only the last lines?

Hi, I need to print lines which are matching with start pattern "SELECT" and END PATTERN ";" and only select the last "select" statement including the ";" . I have attached sample input file and the desired input should be as: INPUT FORMAT: SELECT ABCD, DEFGH, DFGHJ, JKLMN, AXCVB,... (5 Replies)
Discussion started by: nani2019
5 Replies
MIDI::Score(3)						User Contributed Perl Documentation					    MIDI::Score(3)

NAME
MIDI::Score - MIDI scores SYNOPSIS
# it's a long story; see below DESCRIPTION
This module provides functions to do with with MIDI scores. It is used as the basis for all the functions in MIDI::Simple. (Incidentally, MIDI::Opus's draw() method also uses some of the functions in here.) Whereas the events in a MIDI event structure are items whose timing is expressed in delta-times, the timing of items in a score is expressed as an absolute number of ticks from the track's start time. Moreover, pairs of 'note_on' and 'note_off' events in an event structure are abstracted into a single 'note' item in a score structure. 'note' takes the following form: ('note_on', I<start_time>, I<duration>, I<channel>, I<note>, I<velocity>) The problem that score structures are meant to solve is that 1) people definitely don't think in delta-times -- they think in absolute times or in structures based on that (like 'time from start of measure'); 2) people think in notes, not note_on and note_off events. So, given this event structure: ['text_event', 0, 'www.ely.anglican.org/parishes/camgsm/chimes.html'], ['text_event', 0, 'Lord through this hour/ be Thou our guide'], ['text_event', 0, 'so, by Thy power/ no foot shall slide'], ['patch_change', 0, 1, 8], ['note_on', 0, 1, 25, 96], ['note_off', 96, 0, 1, 0], ['note_on', 0, 1, 29, 96], ['note_off', 96, 0, 1, 0], ['note_on', 0, 1, 27, 96], ['note_off', 96, 0, 1, 0], ['note_on', 0, 1, 20, 96], ['note_off', 192, 0, 1, 0], ['note_on', 0, 1, 25, 96], ['note_off', 96, 0, 1, 0], ['note_on', 0, 1, 27, 96], ['note_off', 96, 0, 1, 0], ['note_on', 0, 1, 29, 96], ['note_off', 96, 0, 1, 0], ['note_on', 0, 1, 25, 96], ['note_off', 192, 0, 1, 0], ['note_on', 0, 1, 29, 96], ['note_off', 96, 0, 1, 0], ['note_on', 0, 1, 25, 96], ['note_off', 96, 0, 1, 0], ['note_on', 0, 1, 27, 96], ['note_off', 96, 0, 1, 0], ['note_on', 0, 1, 20, 96], ['note_off', 192, 0, 1, 0], ['note_on', 0, 1, 20, 96], ['note_off', 96, 0, 1, 0], ['note_on', 0, 1, 27, 96], ['note_off', 96, 0, 1, 0], ['note_on', 0, 1, 29, 96], ['note_off', 96, 0, 1, 0], ['note_on', 0, 1, 25, 96], ['note_off', 192, 0, 1, 0], here is the corresponding score sctructure: ['text_event', 0, 'www.ely.anglican.org/parishes/camgsm/chimes.html'], ['text_event', 0, 'Lord through this hour/ be Thou our guide'], ['text_event', 0, 'so, by Thy power/ no foot shall slide'], ['patch_change', 0, 1, 8], ['note', 0, 96, 1, 25, 96], ['note', 96, 96, 1, 29, 96], ['note', 192, 96, 1, 27, 96], ['note', 288, 192, 1, 20, 96], ['note', 480, 96, 1, 25, 96], ['note', 576, 96, 1, 27, 96], ['note', 672, 96, 1, 29, 96], ['note', 768, 192, 1, 25, 96], ['note', 960, 96, 1, 29, 96], ['note', 1056, 96, 1, 25, 96], ['note', 1152, 96, 1, 27, 96], ['note', 1248, 192, 1, 20, 96], ['note', 1440, 96, 1, 20, 96], ['note', 1536, 96, 1, 27, 96], ['note', 1632, 96, 1, 29, 96], ['note', 1728, 192, 1, 25, 96] Note also that scores aren't crucially ordered. So this: ['note', 768, 192, 1, 25, 96], ['note', 960, 96, 1, 29, 96], ['note', 1056, 96, 1, 25, 96], means the same thing as: ['note', 960, 96, 1, 29, 96], ['note', 768, 192, 1, 25, 96], ['note', 1056, 96, 1, 25, 96], The only exception to this is in the case of things like: ['patch_change', 200, 2, 15], ['note', 200, 96, 2, 25, 96], where two (or more) score items happen at the same time and where one affects the meaning of the other. WHAT CAN BE IN A SCORE
Besides the new score structure item "note" (covered above), the possible contents of a score structure can be summarized thus: Whatever can appear in an event structure can appear in a score structure, save that its second parameter denotes not a delta-time in ticks, but instead denotes the absolute number of ticks from the start of the track. To avoid the long periphrase "items in a score structure", I will occasionally refer to items in a score structure as "notes", whether or not they are actually "note" commands. This leaves "event" to unambiguously denote items in an event structure. These, below, are all the items that can appear in a score. This is basically just a repetition of the table in MIDI::Event, with start- time substituting for dtime -- so refer to MIDI::Event for an explanation of what the data types (like "velocity" or "pitch_wheel"). As far as order, the first items are generally the most important: ('note', starttime, duration, channel, note, velocity) ('key_after_touch', starttime, channel, note, velocity) ('control_change', starttime, channel, controller(0-127), value(0-127)) ('patch_change', starttime, channel, patch) ('channel_after_touch', starttime, channel, velocity) ('pitch_wheel_change', starttime, channel, pitch_wheel) ('set_sequence_number', starttime, sequence) ('text_event', starttime, text) ('copyright_text_event', starttime, text) ('track_name', starttime, text) ('instrument_name', starttime, text) ('lyric', starttime, text) ('marker', starttime, text) ('cue_point', starttime, text) ('text_event_08', starttime, text) ('text_event_09', starttime, text) ('text_event_0a', starttime, text) ('text_event_0b', starttime, text) ('text_event_0c', starttime, text) ('text_event_0d', starttime, text) ('text_event_0e', starttime, text) ('text_event_0f', starttime, text) ('end_track', starttime) ('set_tempo', starttime, tempo) ('smpte_offset', starttime, hr, mn, se, fr, ff) ('time_signature', starttime, nn, dd, cc, bb) ('key_signature', starttime, sf, mi) ('sequencer_specific', starttime, raw) ('raw_meta_event', starttime, command(0-255), raw) ('sysex_f0', starttime, raw) ('sysex_f7', starttime, raw) ('song_position', starttime) ('song_select', starttime, song_number) ('tune_request', starttime) ('raw_data', starttime, raw) FUNCTIONS
This module provides these functions: $score2_r = MIDI::Score::copy_structure($score_r) This takes a reference to a score structure, and returns a reference to a copy of it. Example usage: @new_score = @{ MIDI::Score::copy_structure( @old_score ) }; $events_r = MIDI::Score::score_r_to_events_r( $score_r ) ($events_r, $ticks) = MIDI::Score::score_r_to_events_r( $score_r ) This takes a reference to a score structure, and converts it to an event structure, which it returns a reference to. In list context, also returns a second value, a count of the number of ticks that structure takes to play (i.e., the end-time of the temporally last item). $score2_r = MIDI::Score::sort_score_r( $score_r) This takes a reference to a score structure, and returns a reference to a sorted (by time) copy of it. Example usage: @sorted_score = @{ MIDI::Score::sort_score_r( @old_score ) }; $score_r = MIDI::Score::events_r_to_score_r( $events_r ) ($score_r, $ticks) = MIDI::Score::events_r_to_score_r( $events_r ) This takes a reference to an event structure, converts it to a score structure, which it returns a reference to. If called in list context, also returns a count of the number of ticks that structure takes to play (i.e., the end-time of the temporally last item). $ticks = MIDI::Score::score_r_time( $score_r ) This takes a reference to a score structure, and returns a count of the number of ticks that structure takes to play (i.e., the end- time of the temporally last item). MIDI::Score::dump_score( $score_r ) This dumps (via "print") a text representation of the contents of the event structure you pass a reference to. COPYRIGHT
Copyright (c) 1998-2002 Sean M. Burke. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. AUTHOR
Sean M. Burke "sburke@cpan.org" perl v5.8.0 2002-11-16 MIDI::Score(3)
All times are GMT -4. The time now is 04:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy