Using REGEX within SED range search


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using REGEX within SED range search
# 8  
Old 06-11-2009
it should, but not all sed implementations support the '<anything>+' syntax.
to specify one or more instances, use '<anything><anything>*', e.g. '[ ][ ]*'
# 9  
Old 06-11-2009
i've tried the following....

Code:
sed -e '/[ ][ ]*[Ss][Ee][Ll][Ee][Cc][Tt][ ][ ]*/,/;/!d' -e '/;/G'

but still getting the following results... one bad result. Smilie

Quote:
typeset select ion_count=${1}
GOOD;

typeset selection_count=${1}
BAD;

Last edited by danmauer; 06-11-2009 at 12:10 PM..
# 10  
Old 06-11-2009
Code:
sed -e '/[ ][ ]*[Ss][Ee][Ll][Ee][Cc][Tt][ ][ ]*.*;/!d'

# 11  
Old 06-11-2009

You are printing a range: from a line with ' select ' to a line with ';'.

Code:
sed -e '/  *[Ss][Ee][Ll][Ee][Cc][Tt]  */!d' -e '/;/G'

# 12  
Old 06-11-2009
Can the start and end of the range be on the same line? like my 2 data examples above?
# 13  
Old 06-11-2009
Quote:
Originally Posted by danmauer
Can the start and end of the range be on the same line? like my 2 data examples above?

No.

If you only want one line, why ask for more?
# 14  
Old 06-11-2009
ahhhhh.. that's where i was getting confused....

Thanks for your patience.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Sed/awk to delete a regex between range of lines

Hi Guys I am looking for a solution to one problem to remove parentheses in a range of lines. Input file module bist_logic_inst(a, ab , dhd, dhdh , djdj, hdh, djjd, jdj, dhd, dhp, dk ); input a; input ab; input dhd; input djdj; input dhd; output hdh; output djjd; output jdj;... (5 Replies)
Discussion started by: kshitij
5 Replies

2. Shell Programming and Scripting

Search for string on a range of lines

Hi, I am trying to parse a file searching for specific set of string and then within those set of strings finding a keyword. The script works the way that I intended it to be but I thought it could be a lot simpler may be. Any advice will be much appreciated. The script at the moment is as... (1 Reply)
Discussion started by: newbie_01
1 Replies

3. Shell Programming and Scripting

Regex - search and replace

I have file which contains data in the following format all in a single line: BDW_PUBLN_ID DECIMAL(18:0) NOT NULL PRIMARY INDEX ARGO_ACCT_DEP_PI ( OFC_ID ,CSHBX_ID ,TRXN_SEQ_NUM ,PROCG_DT ) PARTITION BY RANGE_N(PROCG_DT BETWEEN DATE '2012-03-01' AND DATE '2014-12-31' EACH INTERVAL '1' MONTH );... (4 Replies)
Discussion started by: ysvsr1
4 Replies

4. Shell Programming and Scripting

Regex : help - How to write a range in ls

Experts, Quick question for you guys: - There are a lot of files. - How to list all files in one command from arch1_171034 to 63 , in the below examples. That means how to list with ls : arch1_171034_667780.dbf to arch1_171063_667780.dbf files. Thanks . (7 Replies)
Discussion started by: rveri
7 Replies

5. Shell Programming and Scripting

Generate Regex numeric range with specific sub-ranges

hi all, Say i have a range like 0 - 1000 and i need to split into diffrent files the lines which are within a specific fixed sub-range. I can achieve this manually but is not scalable if the range increase. E.g cat file1.txt Response time 2 ms Response time 15 ms Response time 101... (12 Replies)
Discussion started by: varu0612
12 Replies

6. UNIX for Dummies Questions & Answers

How to specify beginning-of-line/end-of-line characters inside a regex range

How can I specify special meaning characters like ^ or $ inside a regex range. e.g Suppose I want to search for a string that either starts with '|' character or begins with start-of-line character. I tried the following but it does not work: sed 's/\(\)/<do something here>/g' file1 ... (3 Replies)
Discussion started by: jawsnnn
3 Replies

7. Shell Programming and Scripting

How do I search with regex in one spot?

Hello im new here and i shot stright with question. Mainly i wanna ask , how do i search with regexp in one spot and show the whole thing, what im trying to ask is , for eg. i do ls -l, and i see all the info for the dirs and dats. now say i wanna get all the dats that in their name they start... (2 Replies)
Discussion started by: Goroner
2 Replies

8. Shell Programming and Scripting

Converting perl regex to sed regex

I am having trouble parsing rpm filenames in a shell script.. I found a snippet of perl code that will perform the task but I really don't have time to rewrite the entire script in perl. I cannot for the life of me convert this code into something sed-friendly: if ($rpm =~ /(*)-(*)-(*)\.(.*)/)... (1 Reply)
Discussion started by: suntzu
1 Replies

9. Shell Programming and Scripting

awk search within a range.

I have this kind of file ABC UUIIIIIIIIIIII , HJHKJKL XYZ HHJJJJJJMMM ABC BBOOIO, PPLIOJK XYZ NMJKJKK ABC MMMM ABC OPOPO XYZ LLKLKLL I need to get all data from ABC till XYZ so output should be UUIIIIIIIIIIII (6 Replies)
Discussion started by: dinjo_jo
6 Replies

10. Shell Programming and Scripting

Search files between a date range

Hi people A newbie here, thrown into the deep end. I want to select the group of files with in a range of dates and perform some operation on it. Are there inbuild date libraries i can use? I did read thru the old posts on this topic. Couldnt get much idea :(, basically want to know how I... (7 Replies)
Discussion started by: zcanji
7 Replies
Login or Register to Ask a Question