Regular expression needed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Regular expression needed
# 1  
Old 01-24-2013
Regular expression needed

Hi Folks

i have text file which have oracle table creation script for ex

Code:
create table schema.table_name1 (col1 number,col2 number);
create table schema.table_name2 (col3 number,col4 number);

like that.

here i want only 'table_name' . how can i find ? can you pls help

the output should be
Code:
table_name1
table_name2


Last edited by Scrutinizer; 01-24-2013 at 08:43 AM.. Reason: code tags
# 2  
Old 01-24-2013
Try
Code:
$ awk '{print $4}' FS="[ .]" file
table_name1
table_name2

Not sure if that FS will work on all versions of awk, though.
# 3  
Old 01-24-2013
Ubuntu

Quote:
Originally Posted by coolboy98699
Hi Folks

i have text file which have oracle table creation script for ex

Code:
create table schema.table_name1 (col1 number,col2 number);
create table schema.table_name2 (col3 number,col4 number);

like that.

here i want only 'table_name' . how can i find ? can you pls help

the output should be
table_name1
table_name2

You can use egrep command also
Code:
egrep "table_name." filename1 > filename2

filename1 will contain
Code:
create table schema.table_name1 (col1 number,col2 number);
create table schema.table_name2 (col3 number,col4 number);

filename2 will have
Code:
table_name1
table_name2

Let me know if it works

Last edited by Scott; 01-24-2013 at 07:05 AM.. Reason: Code tags
# 4  
Old 01-24-2013
Code:
 
$ sed 's/.*schema\.\(.* \)(.*/\1/' input.txt
table_name1 
table_name2

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regular Expression needed for the xml

I would like to match the regular below xml snippet by using the following grep command. I want match the lines as well could some please help me .. grep -il "<tokenValue>.*.</tokenValue>\n...*.amey.*.</userName>" ... (6 Replies)
Discussion started by: ameyrk
6 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. UNIX for Dummies Questions & Answers

Regular expression help needed

Hi I need to simplify this reg expression is this right or thanks. (1 Reply)
Discussion started by: drew211
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

Hi In the case expression below,the first condition is if the value is an 8 digit number then do the associated steps. What i want to know is is there a beter way to write this regular expression? ) i tried \{8\} but it didnt work? while ; do case "$1" in )run_date=$1 shift ;;... (4 Replies)
Discussion started by: vinoo128
4 Replies

7. 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

8. Programming

help in regular expression

Hi all, I'm working with flex (version 2.5.4a) on GNU/linux. I need to frame a regular expression which would match cases where word "file" does not occur. Negated character class wont work for me because they enforce "or" clause between different chars (so something like wont work). I would like... (5 Replies)
Discussion started by: Rakesh Ranjan
5 Replies

9. UNIX for Dummies Questions & Answers

Need help in Regular Expression

I have a file with data that looks like - record nullable { final_delim=end ,delim="~%%~" ,quote=none } ( 1_UPC:string; 2_QUANTITY:string; ) I want to fetch the first column that starts with integer. e.g - 1_UPC, 2_QUANTITY. I tried "awk -F ":" -v var1="^0-9" '$1==var1' inschemafile".... (2 Replies)
Discussion started by: mahabunta
2 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