The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
String extract sgaucho Shell Programming and Scripting 8 07-18-2008 01:25 PM
Extract string between <> rakeshou Shell Programming and Scripting 14 11-21-2007 01:10 PM
How to extract a sub-string from a string? JohnHealey UNIX for Dummies Questions & Answers 4 01-22-2007 04:29 AM
Extract String sehgalniraj UNIX for Dummies Questions & Answers 1 09-25-2006 12:35 PM
How to extract a portion of a string from the whole string ds_sastry UNIX for Dummies Questions & Answers 2 09-29-2001 10:40 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-04-2008
madhu.it madhu.it is offline
Registered User
  
 

Join Date: Oct 2008
Location: andhra pradesh
Posts: 10
extract a sub string from a main string

i need a shell program to extract a substring from a main string..
for eg:- main string is madhu..
sub string is mad
o/p:- be mad.
try to solve this one
  #2 (permalink)  
Old 10-04-2008
Bijayant Kumar Bijayant Kumar is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 19
bijayant@bijayant ~ $ cat test
main string is madhu

bijayant@bijayant ~ $ grep -o mad test2 | echo "be mad"
be mad
  #3 (permalink)  
Old 10-04-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,390
Quote:
Originally Posted by Bijayant Kumar View Post
bijayant@bijayant ~ $ cat test
main string is madhu

bijayant@bijayant ~ $ grep -o mad test2 | echo "be mad"
be mad
i didn't get you
  #4 (permalink)  
Old 10-04-2008
Bijayant Kumar Bijayant Kumar is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 19
Quote:
Originally Posted by Bijayant Kumar View Post
bijayant@bijayant ~ $ cat test
main string is madhu

bijayant@bijayant ~ $ grep -o mad test2 | echo "be mad"
be mad
Oopss...sorry,sorry such a silly typo

It will be
bijayant@bijayant ~ $ grep -o mad test | echo "be mad"
be mad
  #5 (permalink)  
Old 10-04-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,390
just echo "be mad" will display be mad..
grep -o is used to show part of matched line.. right??
  #6 (permalink)  
Old 10-04-2008
madhu.it madhu.it is offline
Registered User
  
 

Join Date: Oct 2008
Location: andhra pradesh
Posts: 10
extract substring from mainstring

i need a shell program to extract a substring from a main string..
for eg:- main string is madhu..
sub string is mad
o/p:- mad.
try to solve this one
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:50 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0