Computing.Net > Forums > Unix > how to match pattern on Bash?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

how to match pattern on Bash?

Reply to Message Icon

Name: nelsmy
Date: November 23, 2005 at 00:39:53 Pacific
OS: windows xp
CPU/Ram: pentium 4
Comment:

Below is a perl script, if i want to get the string preceed the match pattern, i can use variable $`, but how do i do it in bash? can anyone show me?

$_ = "this is a sample string";
/sa.*le/; # matches "sample" within the string
# $` is now "this is a "
# $& is now "sample"
# $' is now " string"




Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: how to match pattern on Bash?

how to run .exe on linux(mandrake)? www.computing.net/answers/unix/how-to-run-exe-on-linuxmandrake/5167.html

How to send mail on UNIX to smtp mail www.computing.net/answers/unix/how-to-send-mail-on-unix-to-smtp-mail/2394.html

How To install a DSL Modem in Linux www.computing.net/answers/unix/how-to-install-a-dsl-modem-in-linux/1022.html