Hello,
Despite reading the Pattern Matching chapter in the O'Reilly Sed & Awk book several times and
looking at numerous examples, I cannot seem to get any kind of conditional script to work in my awk scripts!
I am able to do the basic awk and grep script to capture the data but when I do with OR (||) or AND (&&) I keep getting error.
So unable to get selective records.I am pretty new to Unix and can do very basic commands only. Any help would be appreciated.
Thanks very much.
Here is an sample data file I have :
<3icmt001>
Here is a list of application related files which have been found on the remote SMB shares :
+ Software :
\cmdb_web.zip
</3icmt001>
<3idbi002>
- SQLDATA - (readable,writable)
+ Content of this share :
..
DCDB
DTSDB
P8DB
- eventlogs$
+ Content of this share :
..
DCDB
DTSDB
P8DB
- Services
+ Content of this share :
..
DCDB
DTSDB
P8DB
</3idbi002>
I need to get the following output file in order to load the data into my Oracle D/B using SQLLDR:
3icmt001,application,Software,cmdb_web.zip
Field 1 = Computer name
Field 2 = file type
Field 3 = share name
Field 4 = store filename
Note: (Conditions)
1. The next record <3idbi002> will not be selected because it doesn't have file type of "application" or "files" or "others".(Like the sentence
(Here is a list of application related files which have been found on the remote SMB shares
2. There could be multiple store filenames(\cmdb_web.zip) in which case the new row should have the same computer name,file type,share name
and the new store filename.(eg: If the new store filename are : \P8CE-3.5.2-014.exe and \mycount.bat then the new rows will be
3icmt001,application,Software,P8CE-3.5.2-014.exe
3icmt001,application,Software,mycount.bat
3. If there is no file type of "application" or "files" or "others". then cannot select the Computer name or share name. So no new row is created.
========================================================
Here is an example of how I was trying to pick the right number of rows for share name
awk '{ if ($1 ~ /<.*>/ && $1 ~ /Here is a list/ && $1 ~ /^\+ */ ) print $2 }' open_windows_shares1.txt
awk: syntax error near line 1
awk: illegal statement near line 1
If I do a grep I can pick up everything.
grep '\+.*:' open_windows_shares1.txt
+ PECLient353 :
+ TEMP :
+ Software :
+ Content of this share :
+ Content of this share :
+ Content of this share :
+ temp :
+ Siteminder :
+ temp :
+ AscentSV :
+ AscentSV :
+ AscentSV :
+ AscentSV :
+ Reports :
+ Models :
+ TSO Downloads :
+ Temp :
+ Content of this share :
I should not pick up "+ Content of this share :" since it doesn't have the file type.
Thanks very much