Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Print pattern regardless of space between

Shell Programming and Scripting


Closed    
 
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 offline Forum Advisor  
Registered User
 
Join Date: May 2012
Last Activity: 7 December 2016, 2:41 PM EST
Location: Simplicity
Posts: 3,317
Thanks: 254
Thanked 1,076 Times in 975 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: 6 December 2016, 6:10 AM EST
Location: India
Posts: 1,413
Thanks: 101
Thanked 497 Times in 474 Posts

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

Sponsored Links
Closed

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 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 04:11 PM.