search several words with awk command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting search several words with awk command
# 1  
Old 08-06-2010
Computer search several words with awk command

Hello,

I want to test if i find the word CACCIA AND idlck in a file, i have to print a message Ok.

For that , i need to user a awk command with a && logical.
Can you help me ?
Smilie
Code:
### CACCIA: DEBUT ###
if $(grep -wqi "$2" /etc/passwd); then
        [ -f /etc/security/.idlck ] && rm /etc/security/.idlck
        chuser -R files registry=files $2
fi
### CACCIA: FIN ###

# 2  
Old 08-06-2010
Code:
awk '/CACCIA/ || /idlck/ {print "OK"} ' input_file

# 3  
Old 08-06-2010
Something like this?
Code:
awk '
/CACCIA/{c++}
/idlck/{d++}
END{if(c && d)print "OK"}
' file

# 4  
Old 08-06-2010
Bug

Thanks a lot !!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search words in any quote position and then change the words

hi, i need to replace all words in any quote position and then need to change the words inside the file thousand of raw. textfile data : "Ninguno","Confirma","JuicioABC" "JuicioCOMP","Recurso","JuicioABC" "JuicioDELL","Nulidad","Nosino" "Solidade","JuicioEUR","Segundo" need... (1 Reply)
Discussion started by: benjietambling
1 Replies

2. UNIX for Advanced & Expert Users

Pass variable to awk command search string

I must have forgot how to do this, but, I am attempting to enter a variable into an awk / gawk search pattern. I am getting a value from user input to place in a specific section of a 132 character string. my default command is .... gawk --re-interval '/^(.{3}P .{4}CYA.{8}1)/' ... (3 Replies)
Discussion started by: sdeevers
3 Replies

3. Shell Programming and Scripting

awk command for complex search and print

Input: 9999~cbc~100~209~ozzxczcz~10001001001~100~abc10 123~a~sdklfjl~sldoi~~~ksjdfnkjsdf~123456 125~g~sdklfjl~slsdfsdfsdfsdfdoi~~~~~~~~ksjdfnkjsdf~345 127~wera~sdklfjl~sldoi~~~ksjdfnkjsdf~123 128~awer~swerwerdklfjl~sldoi~~~ksjdfnkjsf~1da2345... (7 Replies)
Discussion started by: onesuri
7 Replies

4. Shell Programming and Scripting

Search string within a file and list common words from the line having the search string

Hi, Need your help for this scripting issue I have. I am not really good at this, so seeking your help. I have a file looking similar to this: Hello, i am human and name=ABCD. How are you? Hello, i am human and name=PQRS. I am good. Hello, i am human and name=ABCD. Good bye. Hello, i... (12 Replies)
Discussion started by: royzlife
12 Replies

5. Shell Programming and Scripting

Search several string and convert into a single line for each search string using awk command AIX?.

I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios. Cat test Nov 10, 2012 5:17:53 AM INFO: Request Type Line 1.... (5 Replies)
Discussion started by: laknar
5 Replies

6. Shell Programming and Scripting

Search between two words

Hello, I try to print out with sed or awk the 21.18 between "S3 Temperature" and "GrdC" in a text file. The blanks are all real blanks no tabs. Only the two first chars from temperture are required. So the "21" i need as output. S3 Temperatur 21.18 GrdC No Alarm ... (3 Replies)
Discussion started by: felix123
3 Replies

7. Shell Programming and Scripting

search for a pattern using awk between two words

Hi, how can we search for a pattren between two words? below are the examples input 1)select from table_name c1,c2,c3,c4,fn(),fn2(),c5;-->false 2)select from table_name c1,c2,c3,c4;--True 3)select from table c1, c2, c3, fn(), c4;-->true 4)select from table_name c1, c2, c3;-->true... (11 Replies)
Discussion started by: manasa_vs
11 Replies

8. Shell Programming and Scripting

Awk command for search a string in lspv

I 've got this retourn when i tape the commande lspv: hdisk0 00c3fce454950416 rootvg active hdisk1 00c3fce454950416 rootvg active I want to verify if hdisk0 et hdisk1 have the same pvid (ex : 00c3fce454950416)? Can... (8 Replies)
Discussion started by: khalidou13
8 Replies

9. Shell Programming and Scripting

Awk command for search a string in lspv

I want to know wich hdisk have only one pvid and also display hdisk with two pvid. hdisk1 00c3fcd4e516183f testvg active hdisk2 00c3fcd4e516189b testvg active hdisk3 00c3fcd4e51618ec testvg ... (1 Reply)
Discussion started by: khalidou13
1 Replies

10. Shell Programming and Scripting

Search 3 words

Hi All, I have almost 1000+ files and I want to search specific pattern. Looking forwarded your input. Pls note that need to ignore words in between /* */ Search for: "insert into xyz" (Which procedure contain all 3). Expected output: procedure test1 procedure test2 procedure test3 File... (12 Replies)
Discussion started by: susau_79
12 Replies
Login or Register to Ask a Question