- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- New Line charactre in sed
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 01:10 PM
04-03-2002 01:10 PM
I have a file with no New Lines characters, and would like to put New Line before certain pattern
Say, it looks like aa111bbccdd111eeerr111ttt
and 111 is indicator where new line should start
I tried to use command:
sed -e "s/111/`echo \\\t`111/g"
but it did not work :-(
Can you help me, please?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 01:13 PM
04-03-2002 01:13 PM
Re: New Line charactre in sed
sed 's/[pattern]/\n[pattern]/g'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 01:17 PM
04-03-2002 01:17 PM
Re: New Line charactre in sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 01:35 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 01:38 PM
04-03-2002 01:38 PM
Re: New Line charactre in sed
# cat test|sed 's/111/:111/g'|tr ":" '\012'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 01:39 PM
04-03-2002 01:39 PM
Re: New Line charactre in sed
#!/usr/bin/ksh
echo "aa111bbccdd111eeerr111ttt" |
awk '{X = split($0,A,/111/);
for (i=1; i
}'
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 01:40 PM
04-03-2002 01:40 PM
Re: New Line charactre in sed
I am not a sed expert but I tried :-)
hostAprompt>cat testfile
aa111bbccdd111eeerr111ttt
hostAprompt>sed 's/111/&new/' testfile | tr "new" "\n"
aa111
ewbbccdd111eeerr111ttt
close huh ?
-Shabu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 01:42 PM
04-03-2002 01:42 PM
Re: New Line charactre in sed
Do it globally ...(add g at the end)
sed 's/111/&new/g' testfile | tr "new" "\n"
-Shabu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2002 02:13 PM
04-03-2002 02:13 PM
Re: New Line charactre in sed
See my attached script. The sed command is split on 2 lines. The "\" at the end of the first line escapes the newline that terminates the line. Basically, it is simply continuing the command line on the next line.
It is important that there are no spaces before or after the "\".
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 01:40 AM
04-05-2002 01:40 AM
Re: New Line charactre in sed
Here is a variation on Harry's awk statement.
echo "aa111bbccdd111eeerr111ttt" |
awk -F"111" '{ for ( i = 0 ; i <= NF ; i++ )
print $i }'
This produces the following output:
aa
bbccdd
eeerr
ttt
Joseph.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 01:47 AM
04-05-2002 01:47 AM
Re: New Line charactre in sed
l1:/tmp 108 > perl -lne 'BEGIN{$/="111"}print$_,$/' xx
aa111
bbccdd111
eeerr111
ttt111
l1:/tmp 109 >
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2002 07:26 AM
04-05-2002 07:26 AM
Re: New Line charactre in sed
thank you very much for your replays. I learned a lot :-)
I used Darrell Allen's approach - specail thanks to Darrell - but other's programs are also great!
Thank you again,
Alex