Visit Our UNIX and Linux User Community


Help Needed with 1 liner AWK statement


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help Needed with 1 liner AWK statement
# 1  
Old 07-29-2009
Help Needed with 1 liner AWK statement

Greetings, I attempting to create a line statement that will do the following:

1. Read the input file
2. Extract lines containing certain keep words
3. Print the lines in a tabular format (CSV)

Help is what I have so far:

# cat text.tx | egrep -i -e "(Check Name) | (Risk Level) | (Description) | (Summary) | Recommendation/Fix) | awk -F'[>]' '{print $2}'

When I use the mentioned command, I is looking at column instead of lines. I would like for the Risk, Description, Summary and Recommendation/Fix to be its own column.

Your help would be greatly appreciated.
# 2  
Old 07-29-2009
Please, gives us an an example of input file and desired result.

Jean-Pierre.
# 3  
Old 07-29-2009
An example would be the following:

> Policy Category: Access Control
> Check Name: Access server unrestricted
> Risk Level: Low
> CVE Reference: CVE-NO-MATCH
> Description: Verify that the "Access server" field has been restricted to specific groups and users that should have access to the server.
> Summary: The Access server field specifies which names have specifically been given access to communicate to the server. When the list of names in the Access server field is empty, the server assumes any user not in the deny list is granted access.
> Overview: The "Access server" list specifies which names have specifically been given access to communicate to the server. When the server access list is empty, the server assumes any user not in the deny list is granted access. The server access list works hand in hand with the "Not access server" list and the "Only Allow Access to Users in Directory" (OAAUD) option.

The "Not access server" list will override the "Access server" list. Any user or group listed will be denied access regardless of whether it is also in the "Access server" list.

The "Access server" list will override the OAAUD option. Thus , if the OAAUD option is set, even if a remote server is not listed in the server's directory, if that server is in the "Access server" list it will still be granted access.

Although it is not always necessary, it is recommended that the "Access server" list not be left to allow all user to access the server, but rather be filled out to specify all groups and servers that should have access to the server. This will prevent certain user administration errors from causing an unauthorized user to gain access to the server.
> Recommendation/Fix: To restrict the names allowed access to the server, perform the following steps:

1) Open the Domino Administrator client.
2) Select the menu item "File->Open Server" to access the server to edit.
3) Within the "Configuration" tab click on the "Server" option on the left side of the screen.
4) Under "Server" click on "Current Server Document".
5) Click on the "Security" tab within the server document.
6) Find the "Access Server" list under the "Server Access" section.
7) Enter the groups and servers allowed to access the server.
8) Save the document changes.

As part of a complete database security and compliance program, industry best practices recommend monitoring for known vulnerabilities. Commonly referred to as a compensating control, real-time activity monitoring ensures that databases are protected during the gap in time between discovery of a vulnerability and mitigation of that vulnerability. It is recommended that organizations deploy DbProtect's activity monitoring functionality to ensure the highest level of database security.
> Reference: IBM Search results - United States
> Version Affected: All versions of Domino Server

The output should be the following:

Policy Cat Risk Level Description Summary Recommendation
======== ======= ======== ======= ============


I plan to import the results in an excel spreadsheet.

Thanks!
# 4  
Old 07-29-2009
You can do something like that :
Code:
awk -F': ' -v OFS='\t' '
/^> Policy Category:/ { policy_cat     = $2 }
/^> Risk Level:/      { risk_level     = $2 }
/^> Description:/     { description    = $2 }
/^> Summary:/         { summary        = $2 }
/^> Recommendation:/  { recommendation = $2 }
END { print policy_cat, risk_level, description, summary, recommendation}
' inputfile

Jean-Pierre.
# 5  
Old 07-29-2009
Thanks for your help. This did not work. I got the following error:

OS Inte a buffer overflow exists in the extended stored procedure xp_pty_select.

---------- Post updated at 09:15 AM ---------- Previous update was at 07:04 AM ----------

Does anyone else have suggestions??? Please.
# 6  
Old 07-29-2009
That error doesn't sound related to awk at all. Is your input just a flat file or being generated from something else (possibly database related)?
# 7  
Old 07-30-2009
Does anyone have any suggestions???? Thanks.

Previous Thread | Next Thread
Test Your Knowledge in Computers #654
Difficulty: Easy
DOS was initially released on the IBM System/360.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies

2. Shell Programming and Scripting

awk one liner

The below code is a simple modified sample from a file with millions of lines containing hundreds of extra columns xxx="yyy" ... <app addr="1.2.3.4" rem="1000" type="aaa" srv="server1" usr="user1"/> <app usr="user2" srv="server2" rem="1001" type="aab" addr="1.2.3.5"/>What's the most efficient awk... (2 Replies)
Discussion started by: cabrao
2 Replies

3. Shell Programming and Scripting

HELP with AWK one-liner. Need to employ an If condition inside AWK to check for array variable ?

Hello experts, I'm stuck with this script for three days now. Here's what i need. I need to split a large delimited (,) file into 2 files based on the value present in the last field. Samp: Something.csv bca,adc,asdf,123,12C bca,adc,asdf,123,13C def,adc,asdf,123,12A I need this split... (6 Replies)
Discussion started by: shell_boy23
6 Replies

4. Shell Programming and Scripting

Search & Replace regex Perl one liner to AWK one liner

Thanks for giving your time and effort to answer questions and helping newbies like me understand awk. I have a huge file, millions of lines, so perl takes quite a bit of time, I'd like to convert these perl one liners to awk. Basically I'd like all lines with ISA sandwiched between... (9 Replies)
Discussion started by: verge
9 Replies

5. UNIX for Dummies Questions & Answers

need an awk one liner

example input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 (3 Replies)
Discussion started by: kenneth.mcbride
3 Replies

6. Shell Programming and Scripting

Clarification needed for a SED one liner

I want to use SED to replace all new line characters of a file, I googled and found this one liner sed '{:q;N;s/\n//g;t q}' infile what do :q;N; and t q mean in this script? (6 Replies)
Discussion started by: kevintse
6 Replies

7. Shell Programming and Scripting

combine 2 awks statement into 1 liner

Using these 2 comands to concatenate both outputs into single file: cat testdata | awk 'BEGIN { FS="\n"; RS=""; } /<pattern1>/ {print}' > testdata1 cat testdata| awk '/<pattern2>/,EOF' >> testdata1 is it possible to combine both "awk" into 1-liner? pls advise and thanks in advance. (5 Replies)
Discussion started by: ux4me
5 Replies

8. UNIX for Dummies Questions & Answers

awk one liner

I need a one liner to" find /pattern/ print from x lines before "pattern" to y lines after "pattern" (3 Replies)
Discussion started by: kenneth.mcbride
3 Replies

9. UNIX for Advanced & Expert Users

one liner needed

Hi I have a file say (a.txt) which has following a.txt ---- $$var1=Tom $$var2=Kim I need a one liner which searches the file(a.txt) for $$var1 and returns the value in it(Tom). Thanks in advance Ammu (7 Replies)
Discussion started by: ammu
7 Replies

10. Shell Programming and Scripting

awk one liner

input a 100 200 300 b 400 10 output a 100 a 200 a 300 b 400 b 10 Thanx (6 Replies)
Discussion started by: repinementer
6 Replies

Featured Tech Videos