![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to delete content in a file (delete content only) | kittusri9 | Shell Programming and Scripting | 5 | 05-15-2008 10:12 AM |
| file moving based on file content | melvyn.cochrane | Shell Programming and Scripting | 12 | 02-15-2008 03:10 AM |
| extract content from a file and insert to another file | fredao | Shell Programming and Scripting | 15 | 12-06-2006 04:36 PM |
| Using the content of a file in the name of another | anriot | Shell Programming and Scripting | 2 | 09-18-2006 04:56 PM |
| transfer of specific file content to another file | mem101 | Shell Programming and Scripting | 1 | 10-18-2005 11:01 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Content extract of a file using awk
Hi Everyone,
I have a file with the below content: File1.txt ====== ### ###==> the below table was created for testing1 purpose; ### create table 123 ( field1 date, field2 char(10) primary key(field1) ); ### ###==> the below table was created for testing2 purpose; ### create table abc ( fielda1 date, fielda2 char(10) ); Question: I would like to print only the 'create table' statements like below: Sample Output: =========== create table 123 ( field1 date, field2 char(10) primary key(field1) ); create table abc ( fielda1 date, fielda2 char(10) ); any hints would be much appreciated. Thanks. RaviShankar |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Code:
egrep -v '^#|^$' file1.txt |
|
#3
|
|||
|
|||
|
yeah i can use "grep -v" but i just want to know if this can be done thru' awk?
I want to learn more in awk. |
|
#4
|
||||
|
||||
|
#5
|
||||
|
||||
|
Hi , i agree with you.
Anyway the awk statement is : Code:
awk ' $0 !~ /^#|^$/' file |
|
#6
|
|||
|
|||
|
Code:
awk ' !/^#|^$/' file |
|||
| Google The UNIX and Linux Forums |