Help required to find pattern


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help required to find pattern
# 1  
Old 05-03-2011
Help required to find pattern

Hi All,

I have a oracle code & want to exclude the comments present in the code. Below may be the pattern can be considered for eg.

Code:
-- ALTER TABLE
ALTER TABLE -- To create

In above sample, First line is full commented line as it starts with "--"
Wheras the second line is starting with code but also it is having comments mentioned after "--". So here my requirement is, I want to find the "--" pattern where ever in line and ignore everything after "--".

Please help.
# 2  
Old 05-03-2011
Quote:
Originally Posted by gr8_usk
Hi All,

I have a oracle code & want to exclude the comments present in the code. Below may be the pattern can be considered for eg.

Code:
-- ALTER TABLE
ALTER TABLE -- To create

In above sample, First line is full commented line as it starts with "--"
Wheras the second line is starting with code but also it is having comments mentioned after "--". So here my requirement is, I want to find the "--" pattern where ever in line and ignore everything after "--".

Please help.
This should do it.
Code:
 awk -F'--' '{print $1}' $ORACLE_CODE_FILENAME

removing blank lines is left as an exercise for the reader Smilie
This User Gave Thanks to Skrynesaver For This Post:
# 3  
Old 05-03-2011
Code:
sed 's/--.*//' infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies

2. Shell Programming and Scripting

Help required in searching of pattern.

i m searching a zone file my domain name is abcd.com my zone file looks like this. abcd.com. IN SOA ns1.abcd.com. root.abcd.com. ( abcd.com. 400 IN A 15.1.1.1 Then i am searching that abcd.com have if below ip... (14 Replies)
Discussion started by: learnbash
14 Replies

3. Shell Programming and Scripting

Searching and printing only required pattern

Hi all, i am trying to count the number of logical processors from the below output: # print_manifest | grep "logical processors" 8 cores, 16 logical processors per socket 2 logical processors (2 per socket) i just want to have below output : 16 2 also... (11 Replies)
Discussion started by: omkar.jadhav
11 Replies

4. Shell Programming and Scripting

Sed/awk : to grep only required pattern disk

Hi Experts, Need help with the following: Desired output: Only want to get the output marked in green. The file: --- Physical volumes --- PV Name /dev/disk/disk4704 PV Status available Total PE 6399 Free PE ... (3 Replies)
Discussion started by: rveri
3 Replies

5. Shell Programming and Scripting

sed pattern matching help required

Hi I am trying to pattern match with sed, if it finds a match I need it to insert characters at the 28th position, its working but its also adding an extra space and I don't know why, below is the code. sed 's/715023044/\n&/g' $asn | sed '/^71502304413-000/s/./B4/28' | sed -e :a -e... (4 Replies)
Discussion started by: firefox2k2
4 Replies

6. Shell Programming and Scripting

egrep help required to find pattern

Hi All, Can some one please help me how to grep the comments from "oracle" & "sybase" code. I would like to grep below type of pattern. -- /* */ Please help. (6 Replies)
Discussion started by: gr8_usk
6 Replies

7. Shell Programming and Scripting

Find required files by pattern in xml files and the change the pattern on Linux

Hello, I need to find all *.xml files that matched by pattern on Linux. I need to have written the file name on the screen and then change the pattern in the file just was found. For instance. I can start the script with arguments for keyword and for value, i.e script.sh keyword... (1 Reply)
Discussion started by: yart
1 Replies

8. Shell Programming and Scripting

Goto each directory and subdirectories and grep the required pattern

Hi All, I need your help in finding pattern from files present in different directories. I need to search for a pattern "xyz" from "*.txt" files which are present in different levels of directories as shown. example ------- dir1/subdir1/file.txt dir2/subdir2/subsubdir2/file.txt... (5 Replies)
Discussion started by: imas
5 Replies

9. UNIX for Advanced & Expert Users

Urgent Help required : awk/sed help to find pattern and delete till end of line

Hi, I need help with using an awk or sed filter on the below line ALTER TABLE "ACCOUNT" ADD CONSTRAINT "ACCOUNT_PK" PRIMARY KEY ("ACCT_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "WMC_DATA" LOGGING ENABLE Look for... (1 Reply)
Discussion started by: rajan_san
1 Replies

10. UNIX for Dummies Questions & Answers

grep required pattern and next 2 or 3 lines

dear ones pl.kindly help me 1) how to print(grep) required pattern and following 2 or 3 lines. 2) grep required pattern(to print)+above 2 lines+below 2 or 3 lines.from a report file. ex: we have some report file kf askfjsk fksaj fk skf sjfksjd kff sjfkjs kf jskdjfklsd jfklsdf sdkfjsd fsd... (3 Replies)
Discussion started by: cvvsnm
3 Replies
Login or Register to Ask a Question