Get the two parameter from text file in UNIX.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Get the two parameter from text file in UNIX.
# 1  
Old 06-29-2015
Get the two parameter from text file in UNIX.

Hi there,

In my attachment there is 'Category/Subcategory' & 'Setting'.
Code:
var=$(awk '/^Logon\/Logoff/ {P=0} P {print $0} FNR==1{printf("From file %s:\n", FILENAME)} /^System/ {P=1}' $file |grep -ia "IPsec Driver"              );echo $var

As of now I am able to
Code:
From File: Policies.txt IPsec Driver                            Success and Failure

It will be best if I can just get
Code:
From File: Policies.txt Success and Failure

Code:
Category/Subcategory                 Setting
System
  Security System Extension      Success and Failure
  System Integrity                      Success and Failure
  IPsec Driver                            Success and Failure
  Other System Events              No Auditing
  Security State Change              Success and Failure

The constraint was that they are seperated by multiple spaces.

Last edited by alvinoo; 06-29-2015 at 11:24 PM..
# 2  
Old 06-30-2015
Is that what you're after?
Code:
var=$(awk '
    FNR==1 {printf "From file: %s ", FILENAME}
    /^Logon\/Logoff/ {P=0}
    P && /IPsec/ {print substr($0, 43)}
    /^System/ {P=1}
'test.file)

# 3  
Old 06-30-2015
Why not
Code:
awk '
/^Logon\/Logoff/        {P=0}
P && /IPsec/            {printf "From file: %s; %s\n", FILENAME, substr($0, 43)}
/^System/               {P=1}
' /tmp/audit_nac1051.txt

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Need list of input and output parameter of task in a text file, using shell script

//file begin ===== //some code task abcd_; input x; input y,z; //some comment output w; //some comment reg p; integer q; begin //some code end endtask : abcd_ //some code //file end ===== expected output from above... (1 Reply)
Discussion started by: rishifrnds
1 Replies

2. Shell Programming and Scripting

To call Oracle procedure by reading parameter file in UNIX

hi Guys, is there a way to pass parameter into oracle store procedure by reading date range in file and increment accordingly. Something like this file.txt 01-JAN-2015 03-JAN-2015 sqlplus -s user/pwd@DB execute TEST( to_date( '01-JAN-2015, 'dd.mm.yyyy' ), to_date( '03-JAN-2015', ... (1 Reply)
Discussion started by: rohit_shinez
1 Replies

3. Shell Programming and Scripting

How to pass the parameter in xml file in UNIX shell script?

Hi, I have an XML file like the following... <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ONDEMAND_JOB VERSION="5.1" LOCALE="en_US"> <IMPORT_JOBSET TC_CONNECTION_NAME="default" ENVIRONMENT="PRD" USERNAME="Administrator" PASSWORD="AdminPassword" CALENDAR="Main Monthly Calendar"... (3 Replies)
Discussion started by: Debalina Roy
3 Replies

4. Shell Programming and Scripting

How to pass the parameter in xml file in UNIX shell script?

Hi, I have an XML file like the following... <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ONDEMAND_JOB VERSION="5.1" LOCALE="en_US"> <IMPORT_JOBSET TC_CONNECTION_NAME="default" ENVIRONMENT="PRD" USERNAME="Administrator" PASSWORD="AdminPassword" CALENDAR="Main Monthly Calendar"... (2 Replies)
Discussion started by: Debalina Roy
2 Replies

5. Programming

How to pass parameter from file to sqlplus in UNIX?

i have file in which i have employee id are there and every time number of employee id are different in file means number of count of employee id in file are every time different. 343535435 365765767 343534543 343543543 i want to pass this file to sqlplus and sql command is ... (7 Replies)
Discussion started by: pallvi_mahajan
7 Replies

6. Shell Programming and Scripting

How to get the parameter value from the parameter file in perl?

hi all, i have a parameter file of following format, i want a method which can get the value of specific parameter. parameter file format: <Parameter Name="FileLocationWindows"> <Description> The directory location of the logger file. ... (1 Reply)
Discussion started by: laxmikant.hcl
1 Replies

7. Shell Programming and Scripting

Logging in unix account taking password from a parameter file

Hi All, I am writing a script where it updates a file in an unix account. To update that file i need to be logged in as that account user. say account name is ab01 and its password is passab01. What i want to do is, my script should read login id and password from a parameter file and... (4 Replies)
Discussion started by: pkbond
4 Replies

8. Shell Programming and Scripting

Parameter to text file

I have a file called filename.cg. Which contains the hard-coded value. Name abc Age 23 In another script we are calling the filename.cg perl abc.pl abc 23 should be the parameter. In filename.cg Name 1st parameter Age 2nd parameter (3 Replies)
Discussion started by: sandy1028
3 Replies

9. Shell Programming and Scripting

Performance issue in UNIX while generating .dat file from large text file

Hello Gurus, We are facing some performance issue in UNIX. If someone had faced such kind of issue in past please provide your suggestions on this . Problem Definition: /Few of load processes of our Finance Application are facing issue in UNIX when they uses a shell script having below... (19 Replies)
Discussion started by: KRAMA
19 Replies

10. UNIX for Advanced & Expert Users

How can i read a non text file in unix - ELF-64 executable object file - IA64

The binary file is ELF-64 executable object file - IA64. How i know that the source is Is there any comamnd in unix i can read these kind of files or use a thirty party software? Thanks for your help (8 Replies)
Discussion started by: alexcol
8 Replies
Login or Register to Ask a Question