Help required in writing the regular expression.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help required in writing the regular expression.
# 8  
Old 04-28-2014
Hello,

Still not completly sure about expected output but following may help.

Code:
awk '/^1 1982.*09:56:13.617$/ {print $0; getline; print $0}'  file_name

Thanks,
R. Singh
# 9  
Old 04-28-2014
Quote:
Originally Posted by VSSajjan
similar to the line "
Code:
1 1982        1          testing            init.cc  3001     Apr 25 2014    09:56:13.617

"
Here the numbers and the strings might change
This is very vague. Please specify the criteria by which certain lines would be selected and others would not..
# 10  
Old 04-29-2014
Okay.. let me be clear with question.

i have below lines.

Code:
 1 1982        1          testing            init.cc  3001     Apr 25 2014    09:56:20.083
Start FH Log:
End FH Log.
 0 2014        1          testing            log.cc  3001     Apr 25 2014    07:55:10.032
logging for testing purpose:

Now i need to write regular expression for the line

Code:
 1 1982        1          testing            init.cc  3001     Apr 25 2014    09:56:20.083

such that i get the output
Code:
 1 1982        1          testing            init.cc  3001     Apr 25 2014    09:56:20.083
Start FH Log:
End FH Log.
 0 2014        1          testing            log.cc  3001     Apr 25 2014    07:55:10.032
logging for testing purpose:

It may appear that i need to print all the lines but that is not the case. I need the first section in one go and next section in another go. Hope i have clarified the question.
See that the lines 1 and 4 are different we cannot use the same number and strings.

Last edited by Don Cragun; 04-29-2014 at 03:52 AM.. Reason: Remove double post; fix CODE and ICODE tags.
# 11  
Old 04-29-2014
Quote:
Originally Posted by VSSajjan
It may appear that i need to print all the lines but that is not the case. I need the first section in one go and next section in another go. Hope i have clarified the question.
So, you want to print all lines in the order they came in without modifying them any way, but can't use cat ? What constitutes a 'go'? You want to run the program once to get the first 3 lines, then again to get the second two lines...?

Do the columns mean anything? Explaining what the columns are would help. Right now we have no idea how much they're going to change.

What exactly are you trying to do? Tell us that, not the way you think you need to solve it...
# 12  
Old 04-30-2014
I need regular expression in java for below line
" 1 1982 1 testing init.cc 3001 Apr 25 2014 09:56:20.083"
The numbers and the strings may change.

Let me get the answer for this. i will post my further question again.
# 13  
Old 04-30-2014
This isn't going anywhere. This thread is closed..
This User Gave Thanks to Scrutinizer For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Why Relational Expression is Writing to a Expression?

Hello All, Not sure why this is happening... When the following If Statement is evaluated for some reason it is creating a file in the CWD called '0'. I've seen this happen before, just not in an If Statement... CODE: if then DIR_NAME="$1" DIR_SIZE=0 STATUS="" else... (3 Replies)
Discussion started by: mrm5102
3 Replies

2. UNIX for Advanced & Expert Users

sed: -e expression #1, char 0: no previous regular expression

Hello All, I'm trying to extract the lines between two consecutive elements of an array from a file. My array looks like: problem_arr=(PRS111 PRS213 PRS234) j=0 while } ] do k=`expr $j + 1` sed -n "/${problem_arr}/,/${problem_arr}/p" problemid.txt ---some operation goes... (11 Replies)
Discussion started by: InduInduIndu
11 Replies

3. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies

4. Shell Programming and Scripting

Required help in perl regular expression substitution for this date format

Hi, I have written a small perl script to handle particular date format using perl, but it is not substituting the whole string. Can some one please check on what is the issue with the code. $_ = "Date: November 25, 2010 09:02:01 PM";... (1 Reply)
Discussion started by: sarbjit
1 Replies

5. Shell Programming and Scripting

Integer expression expected: with regular expression

CA_RELEASE has a value of 6. I need to check if that this is a numeric value. if not error. source $CA_VERSION_DATA if * ] then echo "CA_RELESE $CA_RELEASE is invalid" exit -1 fi + source /etc/ncgl/ca_version_data ++ CA_PRODUCT_ID=samxts ++ CA_RELEASE=6 ++ CA_WEEK_NO=7 ++... (3 Replies)
Discussion started by: ketkee1985
3 Replies

6. Shell Programming and Scripting

Regular expression (regex) required

I want to block all special characters except alphanumerics.. and "."(dot ) character currently am using // I want to even block only single dot or multiple dots.. ex: . or .............. should be blocked. please provide me the reg ex. ---------- Post updated at 05:11 AM... (10 Replies)
Discussion started by: shams11
10 Replies

7. Shell Programming and Scripting

Help need in writing Regular Expression

Hi I need some help in writing a Regular expression. I am getting Date format like "Tue Apr 12 8:21:20 2009" I want to change the this format to "Tue Apr 12 2009 8:21:20" using regular expression Looking forward your help Thanks (6 Replies)
Discussion started by: TonySolarisAdmi
6 Replies

8. Linux

Regular expression to extract "y" from "abc/x.y.z" .... i need regular expression

Regular expression to extract "y" from "abc/x.y.z" (2 Replies)
Discussion started by: rag84dec
2 Replies

9. Shell Programming and Scripting

help required in writing the script

Hi All, Please help me in writting the script File contains: ========= 11424444, <basicpage> jfalfksf <dateofbirth>10/02/2005</dateofbrith> jkaklgja lg'd .... 11423224444, <basicpage> jfalfksf <dateofbirth>11/02/2005</dateofbrith> jkaklgja lg'd 11433523224444, <basicpage>... (4 Replies)
Discussion started by: thaduka
4 Replies

10. Shell Programming and Scripting

Regular Expression + Aritmetical Expression

Is it possible to combine a regular expression with a aritmetical expression? For example, taking a 8-numbers caracter sequece and casting each output of a grep, comparing to a constant. THX! (2 Replies)
Discussion started by: Z0mby
2 Replies
Login or Register to Ask a Question