Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Print pattern regardless of space between

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 02-12-2013
anil510 anil510 is offline
Registered User
 
Join Date: Mar 2012
Last Activity: 16 March 2015, 2:50 AM EDT
Posts: 100
Thanks: 47
Thanked 2 Times in 2 Posts
Print pattern regardless of space between

I have this content in file


Code:
sshd : ALL : allow
SSHD   :  all     : ALLOW
sshD  :  All  :       AllOW

What I need is to print the occurrence of "sshd:all" regardless of the spaces between them and if lower/upper case. So all lines should be printed in output when "grepped" or "printed using awk/sed"
Sponsored Links
    #2  
Old Unix and Linux 02-12-2013
MadeInGermany MadeInGermany is online now Forum Advisor  
Registered User
 
Join Date: May 2012
Last Activity: 31 August 2015, 3:35 PM EDT
Location: Simplicity
Posts: 2,578
Thanks: 193
Thanked 788 Times in 712 Posts

Code:
grep -i '^sshd[^-_a-z0-9]*:[^-_a-z0-9]*all[^-_a-z0-9]*:[^-_a-z0-9]*allow'

The Following User Says Thank You to MadeInGermany For This Useful Post:
anil510 (02-12-2013)
Sponsored Links
    #3  
Old Unix and Linux 02-12-2013
anil510 anil510 is offline
Registered User
 
Join Date: Mar 2012
Last Activity: 16 March 2015, 2:50 AM EDT
Posts: 100
Thanks: 47
Thanked 2 Times in 2 Posts
Thanks worked perfectly
    #4  
Old Unix and Linux 02-12-2013
elixir_sinari's Unix or Linux Image
elixir_sinari elixir_sinari is offline Forum Advisor  
Registered User
 
Join Date: Mar 2012
Last Activity: 16 March 2015, 7:53 AM EDT
Location: India
Posts: 1,412
Thanks: 101
Thanked 496 Times in 473 Posts

Code:
grep -i '^[ \t]*sshd[ \t]*:[ \t]*all[ \t]*:' file

Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need one liner to search pattern and print everything expect 6 lines from where pattern match made chidori Shell Programming and Scripting 8 03-15-2012 11:46 AM
Print characters till the next space when the pattern is found gpk_newbie Shell Programming and Scripting 2 10-19-2011 05:02 AM
Print a pattern between the xml tags based on a search pattern oky Shell Programming and Scripting 13 03-21-2011 01:03 PM
Find a pattern and print next all character to next space pierrebjarnfelt Shell Programming and Scripting 8 05-18-2010 06:11 AM
Use to awk to match pattern, and print the pattern grossgermany Shell Programming and Scripting 6 09-23-2009 01:49 PM



All times are GMT -4. The time now is 03:48 PM.