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.

Replace my perl with awk or sed

Shell Programming and Scripting


Reply    
 
Thread Tools Search this Thread Display Modes
    #8  
Old Unix and Linux 07-14-2017   -   Original Discussion by invinzin21
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 19 November 2017, 2:42 AM EST
Location: Amsterdam
Posts: 11,618
Thanks: 516
Thanked 3,380 Times in 2,979 Posts
You are welcome. I made one correction in my post.. Added underscores which are also word characters..


Code:
-E               Use extended regular expressions
-o               Print only the matched (non-empty) parts of a matching line, 
                 with each such part on a separate output line
[[:alnum:].-]+   One or more alphanumeric character or underscore, dot or dash.
\.               A literal dot
(bin|exe)        Either the string "bin" or the string "exe"

Sponsored Links
    #9  
Old Unix and Linux 07-14-2017   -   Original Discussion by invinzin21
migurus migurus is offline
Registered User
 
Join Date: Sep 2008
Last Activity: 8 November 2017, 4:40 PM EST
Location: US
Posts: 296
Thanks: 58
Thanked 33 Times in 31 Posts
Quote:
Originally Posted by invinzin21 View Post
I want something like..


Code:
# cat list_of|grep -E ".exe|bin"
aa.exe
aa.bin
bb.exe

older grep don't have -o option, in that case following your example just say

Code:
tr ' ' '\n' < list_of | grep -E '\.exe|\.bin'

Sponsored Links
Reply

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
Replace [|] in perl irudayaraj Shell Programming and Scripting 5 05-07-2012 11:37 AM
How replace -- character in perl gvk25 Shell Programming and Scripting 1 04-19-2012 02:34 AM
perl find and replace fettie Shell Programming and Scripting 1 09-15-2011 10:05 AM
perl - replace value Shanks Shell Programming and Scripting 5 06-23-2011 04:28 PM
Replace Perl Module name in all Perl scripts rahulrathod Shell Programming and Scripting 2 12-02-2005 01:00 AM



All times are GMT -4. The time now is 04:39 AM.