The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to print the word ss_psm UNIX for Dummies Questions & Answers 0 03-17-2008 11:22 AM
Print the characters in a word chella Shell Programming and Scripting 5 10-17-2007 06:06 AM
Using first word and print their contents using awk cdfd123 Shell Programming and Scripting 6 10-10-2007 12:12 AM
Can a shell script pull the first word (or nth word) off each line of a text file? tricky Shell Programming and Scripting 5 08-17-2006 03:29 AM
Print out just a word from the file Kinki Shell Programming and Scripting 8 02-20-2005 08:40 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 07-06-2008
Registered User
 

Join Date: Jul 2008
Posts: 20
print text between to word using shell

hello all
i need help to print text between -L and \myproject using bash shell command on following text. i am using sed to do but not get success. i want to print only C:\Users\myname\workspace\. how can i do?

g++ -L"C:\Users\myname\workspace\myproject\lib\ffgeneralutil\lib" -L"C:\Users\myname\workspace\myproject\lib\ffsockwrapper\lib" -L"C:\Users\myname\workspace\myproject\MessageHandler\MsgLib\MtContainer\lib" -L"C:\Users\myname\workspace\myproject\lib\ffrs232\lib" -L"C:\Users\myname\workspace\myproject\lib\ffthread\lib" -L"C:\Users\myname\workspace\myproject\lib\md5wrapper\lib" -L"C:\Users\myname\workspace\myproject\lib\fflogger\lib" -L"C:\Users\myname\workspace\myproject\MessageHandler\MsgLib\LzoMessageCompression\lib" -L"C:\Users\myname\workspace\myproject\MessageHandler\MsgLib\MsgIntegrityUtil\lib" -L"C:\Users\myname\workspace\myproject\MessageHandler\MsgLib\MoContainer\lib" -o"myproject" $(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
# Other Targets
clean:
-$(RM) $(OBJS)$(C++_DEPS)$(C_DEPS)$(CC_DEPS)$(CPP_DEPS)$(EXECUTABLES)$(CXX_DEPS)$(C_UPPER_DEPS) myproject
-@echo ' '
Reply With Quote
Forum Sponsor
  #2  
Old 07-06-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,199
Code:
sed 's/-L"\(.*\)mypro.*/\1/'
If this isn't what you mean, clarify your question.

Regards
Reply With Quote
  #3  
Old 07-06-2008
Registered User
 

Join Date: Jul 2008
Posts: 20
sed

no it is not helping. i need only "C:\Users\myname\workspace", part but is printing the whole paragraph. i only want to print above line. dosent matter how many times come in the file. hope i explained the point.

BR
shailesh
Reply With Quote
  #4  
Old 07-06-2008
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 904
Try this variation:

Code:
sed -n 's/.*-L"\([^ ]*\)\\mypro.*/\1/p'
Reply With Quote
  #5  
Old 07-06-2008
Registered User
 

Join Date: Jul 2008
Posts: 20
sed

now it is not printing anything
br
shailesh
Reply With Quote
  #6  
Old 07-06-2008
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 904
I copied and pasted your sample text above into a file called t and ran it, and this is the output I get:

Code:
$ sed -n 's/.*-L"\([^ ]*\)\\mypro.*/\1/p' t
C:\Users\myname\workspace
$
What version of sed are you using, and under what OS?
Reply With Quote
  #7  
Old 07-06-2008
Registered User
 

Join Date: Jul 2008
Posts: 20
sed

my OS is open SUSE 10.3 and sed version is "GNU sed version 4.1.5". surprised why it is not working. i did the same on my machine and nothing comes out.
BR
shailesh
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux, solaris

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:48 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0