Print pattern regardless of space between | Unix Linux Forums | Shell Programming and Scripting

  Unix/Linux Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER 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: 19 February 2015, 11:23 PM EST
Posts: 94
Thanks: 46
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 offline Forum Advisor  
Registered User
 
Join Date: May 2012
Last Activity: 5 March 2015, 4:16 PM EST
Location: Simplicity
Posts: 2,235
Thanks: 153
Thanked 681 Times in 613 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: 19 February 2015, 11:23 PM EST
Posts: 94
Thanks: 46
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: 9 October 2014, 4:50 PM 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

Unix or Linux Image 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 12:46 PM
Print characters till the next space when the pattern is found gpk_newbie Shell Programming and Scripting 2 10-19-2011 06:02 AM
Print a pattern between the xml tags based on a search pattern oky Shell Programming and Scripting 13 03-21-2011 02:03 PM
Find a pattern and print next all character to next space pierrebjarnfelt Shell Programming and Scripting 8 05-18-2010 07:11 AM
Use to awk to match pattern, and print the pattern grossgermany Shell Programming and Scripting 6 09-23-2009 02:49 PM



All times are GMT -4. The time now is 11:56 PM.