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

Thread Tools Search this Thread Display Modes
Old Unix and Linux 07-14-2017
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Join Date: Nov 2008
Last Activity: 23 September 2017, 1:33 PM EDT
Location: Amsterdam
Posts: 11,535
Thanks: 500
Thanked 3,336 Times in 2,944 Posts
You are welcome. I made one correction in my post.. Added underscores which are also word characters..

-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
Old Unix and Linux 07-14-2017
migurus migurus is offline
Registered User
Join Date: Sep 2008
Last Activity: 20 September 2017, 4:38 PM EDT
Location: US
Posts: 295
Thanks: 58
Thanked 33 Times in 31 Posts
Originally Posted by invinzin21 View Post
I want something like..

# cat list_of|grep -E ".exe|bin"

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

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

Sponsored Links

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

All times are GMT -4. The time now is 09:36 PM.