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
# 8  
Old 07-06-2008
sed

just to note-
the paragraph i have given is only a part of file. the actual file is makefile for C++ project. which containing so many lines of the same text.
# 9  
Old 07-06-2008
sed

original it is like following

-include ../makefile.defs
# Add inputs and outputs from these tool invocations to the build variables
# All Target
all: myproject
# Tool invocations
myproject: $(OBJS) $(USER_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: GCC C++ Linker'
g++ -L"/home/myname/workspace/myproject/lib/ffgeneralutil/lib" -L"/home/myname/workspace/myproject/lib/ffsockwrapper/lib" -L"/home/myname/workspace/myproject/MessageHandler/MsgLib/MtContainer/lib" -L"/home/myname/workspace/myproject/lib/ffrs232/lib" -L"/home/myname/workspace/myproject/lib/ffthread/lib" -L"/home/myname/workspace/myproject/lib/md5wrapper/lib" -L"/home/myname/workspace/myproject/lib/fflogger/lib" -L"/home/myname/workspace/myproject/MessageHandler/MsgLib/LzoMessageCompression/lib" -L"/home/myname/workspace/myproject/MessageHandler/MsgLib/MsgIntegrityUtil/lib" -L"/home/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 ' '
.PHONY: all clean dependents
.SECONDARY:
# 10  
Old 07-07-2008
Well, obviously it won't work, because the sample input you gave us is using Windows backslashes, and the actual input only contains Unix forward slashes.

You should be able to figure out how to change the sed script to make it work in that scenario.
# 11  
Old 07-07-2008
sed

thanks a lt. now it works for linux also as follows -

sed -n 's/.*-L"\([^ ]*\)myproject.*/\1/p'
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