Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 25 Oct 2014, 08:19
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
regexp for multiline string
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message
rumburak24

Joined: 25 Mar 2010
Posts: 1

PostPosted: Thu 25 Mar 2010, 03:58    Post_subject:  regexp for multiline string
Sub_title: regular expression
 

Hello I am new to reg. exp. in Linux. I try to write a rule for bash.

I have a string like this:

pattern="line 1: Hello, this line is just a report to user....
line2: this line is a separator between two lines
line 3: This line includes pattern. This line was generated in for command."

I would like to get two new string from it:
pattern, including line 3 - without \n - new line mark.
report, including line 1 - without \n - new line mark.

I tried some thing but no result.

Thanks for advice

edit - Solved
$(echo "$pattern" | sed -n '1p')
$(echo "$pattern" | sed -n '3p')
Back to top
View user's profile Send_private_message 
sunburnt


Joined: 08 Jun 2005
Posts: 5037
Location: Arizona, U.S.A.

PostPosted: Fri 02 Apr 2010, 16:01    Post_subject:  

Hi rumburak24; If I understand you correctly you want to print out 2 lines without a new line?
2 ways come to my mind:
This outputs the text without a new line: echo -c (text)
Or a list ( more than one line ) can be output without the newlines by: echo $LIST
Having double quotes echos the new lines, like this: echo "$LIST"
But without the double quotes it doesn`t echo the new lines: echo $LIST

If this isn`t what you wanted, please restate your Q...
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0369s ][ Queries: 11 (0.0034s) ][ GZIP on ]