Sponsored Content
Top Forums Shell Programming and Scripting Extract the lines from input file Post 302436053 by sandy1028 on Friday 9th of July 2010 08:02:35 AM
Old 07-09-2010
sed -n '/[5\/Jul\/2010:06:00:00/,/[6\/Jul\/2010:09:00:00/p' soredfile.tsv > output
sed: -e expression #1, char 50: unterminated address regex

Code:
b    [5/Jul/2010:07:00:10
a    [5/Jul/2010:06:00:09
b    [5/Jul/2010:07:00:10
c    [5/Jul/2010:07:10:16
d    [5/Jul/2010:08:00:10
e    [5/Jul/2010:09:00:10
f    [5/Jul/2010:10:00:10
h    [5/Jul/2010:11:00:10
i    [5/Jul/2010:12:00:20
j    [5/Jul/2010:13:00:10
k    [5/Jul/2010:14:00:10
l    [5/Jul/2010:15:00:30
m    [5/Jul/2010:16:00:10
n    [5/Jul/2010:17:00:10
o    [5/Jul/2010:18:00:10
p    [5/Jul/2010:19:00:40
q    [5/Jul/2010:20:00:10
a    [5/Jul/2010:21:00:10
b    [5/Jul/2010:22:00:50
v    [5/Jul/2010:23:00:20
g    [6/Jul/2010:01:00:10
k    [6/Jul/2010:02:00:10
i    [6/Jul/2010:03:00:14
j    [6/Jul/2010:04:00:10
k    [6/Jul/2010:05:00:18
l    [6/Jul/2010:06:00:10
m    [6/Jul/2010:07:00:10
n    [6/Jul/2010:08:00:19
n    [6/Jul/2010:09:00:10



---------- Post updated at 04:47 AM ---------- Previous update was at 04:13 AM ----------

Thanks, this worked fine.

Another problem is

I have the date in the variable as 20100705 and 20100706.

How to convert the date as 5/Jul/2010 and 6/Jul/2010 and pass the dates as a variable in the sed command


sort -k2 tmp.tsv | sed -n '/\[5\/Jul\/2010:06:00:00/,/\[6\/Jul\/2010:09:00:00/p' > tab.tsv

---------- Post updated at 07:02 AM ---------- Previous update was at 04:47 AM ----------

How to pass the variable
$date1
$date2
where $date1 is ' 6\/Jul\/2010'
and $date2 is '7\/Jul\/2010'
sort -k4 tmp.tsv | sed -n '/\[$date1:06:00:00/,/\[$date2:09:00:00/p' > tab.tsv
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to extract a sequence of n lines from a file

Hi I want to be able to extract a sequence of n lines from a file. ideas, commands and suggestions would be highly appreciated. Thanks (4 Replies)
Discussion started by: 0ktalmagik
4 Replies

2. Shell Programming and Scripting

extract particular lines from text file

I have two files file A which have a number in every row and file B which contains few hundred thousand rows with about 300 characters in each row (csv) What I need is to extract whole rows from B file (only these which numbers are indicated in A file) I also need to use cygwin. Any... (7 Replies)
Discussion started by: gunio
7 Replies

3. Shell Programming and Scripting

how do i join two lines from a input file

HI all, i have a input file,i have to join 2nd line into firstline and 4th line into 2nd line and so on.. for this we also consider odd no. of line.It's operate on original input file but output file should temp file. like .. filename=cdr.cfg line1 line2 line3 line4Desired output should be... (9 Replies)
Discussion started by: suryanarayan
9 Replies

4. Shell Programming and Scripting

input text at certain lines of a file

Hi, I have an xml file which will be edited by the user. I would like to get input from user and insert that at line 40 of the xml file. PLease can some one help me to know how to insert the text at specified line using shell script. (6 Replies)
Discussion started by: sunrexstar
6 Replies

5. Shell Programming and Scripting

Extract some lines from one file and add those lines to current file

hi, i have two files. file1.sh echo "unix" echo "linux" file2.sh echo "unix linux forums" now the output i need is $./file2.sh unix linux forums (3 Replies)
Discussion started by: snreddy_gopu
3 Replies

6. Shell Programming and Scripting

Extract particular lines from a file

Hi all, I have a file with many records with information as given below ID A16L2_HUMAN Reviewed; 619 AA. AC Q8NAA4; A5PL30; B2RPK5; Q658V4; Q6PID3; Q8NBG0; DT 20-MAY-2008, integrated into UniProtKB/Swiss-Prot. DT 20-MAY-2008, sequence version 2. DT ... (1 Reply)
Discussion started by: kaav06
1 Replies

7. Shell Programming and Scripting

How to extract certain lines from a file?

Hi guys I have a several thousands line file in the following format: n817 -------------------------------------------------- n842 -------------------------------------------------- n877 -------------------------------------------------- n513 /bb/data/rmt2db.lrl:JBSKDB 31915 75... (4 Replies)
Discussion started by: aoussenko
4 Replies

8. Shell Programming and Scripting

Removing multiple lines from input file, if multiple lines match a pattern.

GM, I have an issue at work, which requires a simple solution. But, after multiple attempts, I have not been able to hit on the code needed. I am assuming that sed, awk or even perl could do what I need. I have an application that adds extra blank page feeds, for multiple reports, when... (7 Replies)
Discussion started by: jxfish2
7 Replies

9. Shell Programming and Scripting

Extract lines from a file

Hi all; Here is my file which contains a list of files (recent versions of files are in red). This file is dynamic, files versions can change at any time (versions can increment) filename ------------------------------------------------------- ... (8 Replies)
Discussion started by: chercheur111
8 Replies

10. Shell Programming and Scripting

Bash to extract file prefix and from input to use in output

In the bash below which does execute I am trying to extract the contents of ${id} is 1234, as ${id} stores the variable that changes each time. After the path is removed the contents of ${id} are stored in pref, so they can be used in the output. Currently I am not able to extract the 1234 in the... (6 Replies)
Discussion started by: cmccabe
6 Replies
Test::Inline::Extract(3pm)				User Contributed Perl Documentation				Test::Inline::Extract(3pm)

NAME
Test::Inline::Extract - Extract relevant Pod sections from source code. DESCRIPTION
The Test::Inline::Extract package extracts content interesting to Test::Inline from source files. METHODS
new $file | $source The "new" constructor creates a new Extract object. It is passed either a file name from which the source code would be loaded, or a reference to a string that directly contains source code. Returns a new "Test::Inline::Extract" object or "undef" on error. elements my $elements = $Extract->elements; The "elements" method extracts from the Pod any parts of the file that are relevant to the extraction and generation process of "Test::Inline". The elements will be either a package statements, or a section of inline unit tests. They will only be returned if there is at least one section of inline unit tests. Returns a reference to an array of package strings and sections of inline unit tests. Returns false if there are no sections containing inline unit tests. TO DO
- For certain very complex cases, add a more intensive alternative parser based on PPI SUPPORT
See the main SUPPORT section. AUTHOR
Adam Kennedy <adamk@cpan.org>, <http://ali.as/> COPYRIGHT
Copyright 2004 - 2010 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.12.4 2010-11-22 Test::Inline::Extract(3pm)
All times are GMT -4. The time now is 08:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy