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

  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 Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-12-2013
anil510 anil510 is offline
Registered User
 
Join Date: Mar 2012
Last Activity: 28 June 2014, 3:33 PM EDT
Posts: 76
Thanks: 38
Thanked 1 Time in 1 Post
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 02-12-2013
MadeInGermany MadeInGermany is offline Forum Advisor  
Registered User
 
Join Date: May 2012
Last Activity: 1 September 2014, 6:21 AM EDT
Location: Simplicity
Posts: 1,849
Thanks: 119
Thanked 535 Times in 484 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 02-12-2013
anil510 anil510 is offline
Registered User
 
Join Date: Mar 2012
Last Activity: 28 June 2014, 3:33 PM EDT
Posts: 76
Thanks: 38
Thanked 1 Time in 1 Post
Thanks worked perfectly
    #4  
Old 02-12-2013
elixir_sinari's Avatar
elixir_sinari elixir_sinari is offline Forum Advisor  
Gotham Knight
 
Join Date: Mar 2012
Last Activity: 25 August 2014, 2:00 AM EDT
Location: India
Posts: 1,412
Thanks: 101
Thanked 495 Times in 472 Posts

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

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 07:22 AM.