print text between to word using shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting print text between to word using shell
# 1  
Old 07-06-2008
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 ' '
# 2  
Old 07-06-2008
Code:
sed 's/-L"\(.*\)mypro.*/\1/'

If this isn't what you mean, clarify your question.

Regards
# 3  
Old 07-06-2008
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
# 4  
Old 07-06-2008
Try this variation:

Code:
sed -n 's/.*-L"\([^ ]*\)\\mypro.*/\1/p'

# 5  
Old 07-06-2008
sed

now it is not printing anything Smilie
br
shailesh
# 6  
Old 07-06-2008
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?
# 7  
Old 07-06-2008
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search for a specific word and print only the word from the input file

Hi, I have a sample file as shown below, I am looking for sed or any command which prints the complete word only from the input file. Ex: $ cat "sample.log" I am searching for a word which is present in this file We can do a pattern search using grep but I need to cut only the word which... (1 Reply)
Discussion started by: mohan_kumarcs
1 Replies

2. Shell Programming and Scripting

[Solved] Search for a word and print the next word

Hi, I am trying to search for a word and print the next word. For example: My text is "<TRANSFORMATION TYPE ="Lookup Procedure">" I am searching for "TYPE" and trying to print ="Lookup Procedure" I have written a code like following: echo $line | nawk... (4 Replies)
Discussion started by: sampoorna
4 Replies

3. Shell Programming and Scripting

How to replace word with multiline text using shell scripting.

Hi all I have data files which contain data as shown below: Line 5: FIDE INST_DESC: DIAM Co Ltd/Japan => MAID Co Ltd/Japan INST_NME: DIAM Co Ltd/Japan => MAID Co Ltd/Japan Line 6: FIDE INST_DESC: DIAM DL/Pimco US Bond Open Born in the USA => MAID DL/Pimco US Bond Open Born in the... (6 Replies)
Discussion started by: Ganesh_more
6 Replies

4. Shell Programming and Scripting

perl lwp find word and print next word :)

hi all, I'm new there, I'm just playing with perl and lwp and I just successfully created a script for log in to a web site with post. I have a response but I would like to have something like this: I have in my response lines like: <div class="sender">mimi020</div> <some html code.....>... (3 Replies)
Discussion started by: vogueestylee
3 Replies

5. Shell Programming and Scripting

Reading a word from a text file into shell script

Hi, I am new to shell programming.I need to write a script that would accept a word from each line fo an input text file.Can anyone help me with this?Exact requirement: word1 word2 word3 (separated by space) .Now I need word3 from each such line in the text file. Thanks in Advance, Manish (3 Replies)
Discussion started by: manish007
3 Replies

6. Shell Programming and Scripting

How ti Grep for a word and print the next word

Hi can we grep for a word and print the next word of the greped word? ex:- create or replace function function_name create function function_name we should search for word "function" and output next word "function_name" from both lines. (3 Replies)
Discussion started by: manasa_vs
3 Replies

7. UNIX for Dummies Questions & Answers

Script to search for a particular word in files and print the word and path name

Hi, i am new to unix shell scripting and i need a script which would search for a particular word in all the files present in a directory. The output should have the word and file path name. For example: "word" "path name". Thanks for the reply in adv,:) (3 Replies)
Discussion started by: virtual_45
3 Replies

8. Shell Programming and Scripting

shell script to print particular column into text file

hi everyone, i need a script which would just print column into a text file nmap 10.226.112.222 PORT STATE SERVICE 7/tcp open echo 13/tcp open daytime 22/tcp open ssh 23/tcp open telnet 37/tcp open time 1100/tcp open unknown above nmap command gives us open ports on that IP. can... (6 Replies)
Discussion started by: anand121
6 Replies

9. Shell Programming and Scripting

How to find and print the last word of each line from a text file

Can any one help us in finding the the last word of each line from a text file and print it. eg: 1st --> aaa bbbb cccc dddd eeee ffff ee 2nd --> aab ered er fdf ere ww ww f the o/p should be a below. ee f (1 Reply)
Discussion started by: naveen_sangam
1 Replies

10. Shell Programming and Scripting

Can a shell script pull the first word (or nth word) off each line of a text file?

Greetings. I am struggling with a shell script to make my life simpler, with a number of practical ways in which it could be used. I want to take a standard text file, and pull the 'n'th word from each line such as the first word from a text file. I'm struggling to see how each line can be... (5 Replies)
Discussion started by: tricky
5 Replies
Login or Register to Ask a Question