How to break line after matching case but needs to go back a couple of characters
up vote
2
down vote
favorite
I have the following sample:
1. TNT 00:00 2. Swing From The Gutters 7:34 3. Ten-Day Interval 13:29 4. I Set My Face To The Hillside 18:16 5. The Equator 24:26 6. A Simple Way To Go Faster Than Light That Does Not Work 28:27 7. The Suspension Bridge At Iguazu Falls 32:03 8. Four-Day Interval 37:42 9. In Sarah, Mencken, Christ And Beethoven There Were Women And Men 42:29 10. Almost Always Is Nearly Enough 50:01 11. Jetty 52:45 12. Everglade 1:01:09 1:05:32
Which I want to convert into:
1. TNT 00:00
2. Swing From The Gutters 7:34
3. Ten-Day Interval 13:29
4. I Set My Face To The Hillside 18:16
5. The Equator 24:26
6. A Simple Way To Go Faster Than Light That Does Not Work 28:27
7. The Suspension Bridge At Iguazu Falls 32:03
8. Four-Day Interval 37:42
9. In Sarah, Mencken, Christ And Beethoven There Were Women And Men 42:29
10. Almost Always Is Nearly Enough 50:01
11. Jetty 52:45
12. Everglade 1:01:09 1:05:32
The logical path I was following is that I know there will always be a "dot" (.) that comes with the number of the track and I can use it as a guideline for the breaks. The trouble is, it has to crawl back one or two characters in order to keep the number of the tracks.
text-processing awk sed text-formatting gawk
New contributor
fdonadon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
2
down vote
favorite
I have the following sample:
1. TNT 00:00 2. Swing From The Gutters 7:34 3. Ten-Day Interval 13:29 4. I Set My Face To The Hillside 18:16 5. The Equator 24:26 6. A Simple Way To Go Faster Than Light That Does Not Work 28:27 7. The Suspension Bridge At Iguazu Falls 32:03 8. Four-Day Interval 37:42 9. In Sarah, Mencken, Christ And Beethoven There Were Women And Men 42:29 10. Almost Always Is Nearly Enough 50:01 11. Jetty 52:45 12. Everglade 1:01:09 1:05:32
Which I want to convert into:
1. TNT 00:00
2. Swing From The Gutters 7:34
3. Ten-Day Interval 13:29
4. I Set My Face To The Hillside 18:16
5. The Equator 24:26
6. A Simple Way To Go Faster Than Light That Does Not Work 28:27
7. The Suspension Bridge At Iguazu Falls 32:03
8. Four-Day Interval 37:42
9. In Sarah, Mencken, Christ And Beethoven There Were Women And Men 42:29
10. Almost Always Is Nearly Enough 50:01
11. Jetty 52:45
12. Everglade 1:01:09 1:05:32
The logical path I was following is that I know there will always be a "dot" (.) that comes with the number of the track and I can use it as a guideline for the breaks. The trouble is, it has to crawl back one or two characters in order to keep the number of the tracks.
text-processing awk sed text-formatting gawk
New contributor
fdonadon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I have the following sample:
1. TNT 00:00 2. Swing From The Gutters 7:34 3. Ten-Day Interval 13:29 4. I Set My Face To The Hillside 18:16 5. The Equator 24:26 6. A Simple Way To Go Faster Than Light That Does Not Work 28:27 7. The Suspension Bridge At Iguazu Falls 32:03 8. Four-Day Interval 37:42 9. In Sarah, Mencken, Christ And Beethoven There Were Women And Men 42:29 10. Almost Always Is Nearly Enough 50:01 11. Jetty 52:45 12. Everglade 1:01:09 1:05:32
Which I want to convert into:
1. TNT 00:00
2. Swing From The Gutters 7:34
3. Ten-Day Interval 13:29
4. I Set My Face To The Hillside 18:16
5. The Equator 24:26
6. A Simple Way To Go Faster Than Light That Does Not Work 28:27
7. The Suspension Bridge At Iguazu Falls 32:03
8. Four-Day Interval 37:42
9. In Sarah, Mencken, Christ And Beethoven There Were Women And Men 42:29
10. Almost Always Is Nearly Enough 50:01
11. Jetty 52:45
12. Everglade 1:01:09 1:05:32
The logical path I was following is that I know there will always be a "dot" (.) that comes with the number of the track and I can use it as a guideline for the breaks. The trouble is, it has to crawl back one or two characters in order to keep the number of the tracks.
text-processing awk sed text-formatting gawk
New contributor
fdonadon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I have the following sample:
1. TNT 00:00 2. Swing From The Gutters 7:34 3. Ten-Day Interval 13:29 4. I Set My Face To The Hillside 18:16 5. The Equator 24:26 6. A Simple Way To Go Faster Than Light That Does Not Work 28:27 7. The Suspension Bridge At Iguazu Falls 32:03 8. Four-Day Interval 37:42 9. In Sarah, Mencken, Christ And Beethoven There Were Women And Men 42:29 10. Almost Always Is Nearly Enough 50:01 11. Jetty 52:45 12. Everglade 1:01:09 1:05:32
Which I want to convert into:
1. TNT 00:00
2. Swing From The Gutters 7:34
3. Ten-Day Interval 13:29
4. I Set My Face To The Hillside 18:16
5. The Equator 24:26
6. A Simple Way To Go Faster Than Light That Does Not Work 28:27
7. The Suspension Bridge At Iguazu Falls 32:03
8. Four-Day Interval 37:42
9. In Sarah, Mencken, Christ And Beethoven There Were Women And Men 42:29
10. Almost Always Is Nearly Enough 50:01
11. Jetty 52:45
12. Everglade 1:01:09 1:05:32
The logical path I was following is that I know there will always be a "dot" (.) that comes with the number of the track and I can use it as a guideline for the breaks. The trouble is, it has to crawl back one or two characters in order to keep the number of the tracks.
text-processing awk sed text-formatting gawk
text-processing awk sed text-formatting gawk
New contributor
fdonadon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
fdonadon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited yesterday
Jeff Schaller
37.5k1052121
37.5k1052121
New contributor
fdonadon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 2 days ago
fdonadon
112
112
New contributor
fdonadon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
fdonadon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
fdonadon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
4
down vote
At least with GNU sed, you can insert a newline before all but the first matching sequence using a 2g modifier:
sed -E 's/[0-9]+./n&/2g' file
1
TheNgmeans "replace globally but start at the Nth occurrence", right?
– terdon♦
2 days ago
@terdon yes that's right - or as the manual puts it, "ignore matches before the numberth, and then match and replace all matches from the numberth on"
– steeldriver
2 days ago
add a comment |
up vote
4
down vote
Just capture the number and the dot and insert a newline before them:
$ perl -pe 's/s(d+.)/n$1/g' file
1. TNT 00:00
2. Swing From The Gutters 7:34
3. Ten-Day Interval 13:29
4. I Set My Face To The Hillside 18:16
5. The Equator 24:26
6. A Simple Way To Go Faster Than Light That Does Not Work 28:27
7. The Suspension Bridge At Iguazu Falls 32:03
8. Four-Day Interval 37:42
9. In Sarah, Mencken, Christ And Beethoven There Were Women And Men 42:29
10. Almost Always Is Nearly Enough 50:01
11. Jetty 52:45
12. Everglade 1:01:09 1:05:32
I'd just like to point out that both answers on this question came in: (a) 10.5 minutes after it was asked, and more amazingly, (b) 15 seconds apart. (#TooSlow, @terdon! 😉)
– FeRD
yesterday
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
At least with GNU sed, you can insert a newline before all but the first matching sequence using a 2g modifier:
sed -E 's/[0-9]+./n&/2g' file
1
TheNgmeans "replace globally but start at the Nth occurrence", right?
– terdon♦
2 days ago
@terdon yes that's right - or as the manual puts it, "ignore matches before the numberth, and then match and replace all matches from the numberth on"
– steeldriver
2 days ago
add a comment |
up vote
4
down vote
At least with GNU sed, you can insert a newline before all but the first matching sequence using a 2g modifier:
sed -E 's/[0-9]+./n&/2g' file
1
TheNgmeans "replace globally but start at the Nth occurrence", right?
– terdon♦
2 days ago
@terdon yes that's right - or as the manual puts it, "ignore matches before the numberth, and then match and replace all matches from the numberth on"
– steeldriver
2 days ago
add a comment |
up vote
4
down vote
up vote
4
down vote
At least with GNU sed, you can insert a newline before all but the first matching sequence using a 2g modifier:
sed -E 's/[0-9]+./n&/2g' file
At least with GNU sed, you can insert a newline before all but the first matching sequence using a 2g modifier:
sed -E 's/[0-9]+./n&/2g' file
answered 2 days ago
steeldriver
33.9k34983
33.9k34983
1
TheNgmeans "replace globally but start at the Nth occurrence", right?
– terdon♦
2 days ago
@terdon yes that's right - or as the manual puts it, "ignore matches before the numberth, and then match and replace all matches from the numberth on"
– steeldriver
2 days ago
add a comment |
1
TheNgmeans "replace globally but start at the Nth occurrence", right?
– terdon♦
2 days ago
@terdon yes that's right - or as the manual puts it, "ignore matches before the numberth, and then match and replace all matches from the numberth on"
– steeldriver
2 days ago
1
1
The
Ng means "replace globally but start at the Nth occurrence", right?– terdon♦
2 days ago
The
Ng means "replace globally but start at the Nth occurrence", right?– terdon♦
2 days ago
@terdon yes that's right - or as the manual puts it, "ignore matches before the numberth, and then match and replace all matches from the numberth on"
– steeldriver
2 days ago
@terdon yes that's right - or as the manual puts it, "ignore matches before the numberth, and then match and replace all matches from the numberth on"
– steeldriver
2 days ago
add a comment |
up vote
4
down vote
Just capture the number and the dot and insert a newline before them:
$ perl -pe 's/s(d+.)/n$1/g' file
1. TNT 00:00
2. Swing From The Gutters 7:34
3. Ten-Day Interval 13:29
4. I Set My Face To The Hillside 18:16
5. The Equator 24:26
6. A Simple Way To Go Faster Than Light That Does Not Work 28:27
7. The Suspension Bridge At Iguazu Falls 32:03
8. Four-Day Interval 37:42
9. In Sarah, Mencken, Christ And Beethoven There Were Women And Men 42:29
10. Almost Always Is Nearly Enough 50:01
11. Jetty 52:45
12. Everglade 1:01:09 1:05:32
I'd just like to point out that both answers on this question came in: (a) 10.5 minutes after it was asked, and more amazingly, (b) 15 seconds apart. (#TooSlow, @terdon! 😉)
– FeRD
yesterday
add a comment |
up vote
4
down vote
Just capture the number and the dot and insert a newline before them:
$ perl -pe 's/s(d+.)/n$1/g' file
1. TNT 00:00
2. Swing From The Gutters 7:34
3. Ten-Day Interval 13:29
4. I Set My Face To The Hillside 18:16
5. The Equator 24:26
6. A Simple Way To Go Faster Than Light That Does Not Work 28:27
7. The Suspension Bridge At Iguazu Falls 32:03
8. Four-Day Interval 37:42
9. In Sarah, Mencken, Christ And Beethoven There Were Women And Men 42:29
10. Almost Always Is Nearly Enough 50:01
11. Jetty 52:45
12. Everglade 1:01:09 1:05:32
I'd just like to point out that both answers on this question came in: (a) 10.5 minutes after it was asked, and more amazingly, (b) 15 seconds apart. (#TooSlow, @terdon! 😉)
– FeRD
yesterday
add a comment |
up vote
4
down vote
up vote
4
down vote
Just capture the number and the dot and insert a newline before them:
$ perl -pe 's/s(d+.)/n$1/g' file
1. TNT 00:00
2. Swing From The Gutters 7:34
3. Ten-Day Interval 13:29
4. I Set My Face To The Hillside 18:16
5. The Equator 24:26
6. A Simple Way To Go Faster Than Light That Does Not Work 28:27
7. The Suspension Bridge At Iguazu Falls 32:03
8. Four-Day Interval 37:42
9. In Sarah, Mencken, Christ And Beethoven There Were Women And Men 42:29
10. Almost Always Is Nearly Enough 50:01
11. Jetty 52:45
12. Everglade 1:01:09 1:05:32
Just capture the number and the dot and insert a newline before them:
$ perl -pe 's/s(d+.)/n$1/g' file
1. TNT 00:00
2. Swing From The Gutters 7:34
3. Ten-Day Interval 13:29
4. I Set My Face To The Hillside 18:16
5. The Equator 24:26
6. A Simple Way To Go Faster Than Light That Does Not Work 28:27
7. The Suspension Bridge At Iguazu Falls 32:03
8. Four-Day Interval 37:42
9. In Sarah, Mencken, Christ And Beethoven There Were Women And Men 42:29
10. Almost Always Is Nearly Enough 50:01
11. Jetty 52:45
12. Everglade 1:01:09 1:05:32
answered 2 days ago
terdon♦
127k31245422
127k31245422
I'd just like to point out that both answers on this question came in: (a) 10.5 minutes after it was asked, and more amazingly, (b) 15 seconds apart. (#TooSlow, @terdon! 😉)
– FeRD
yesterday
add a comment |
I'd just like to point out that both answers on this question came in: (a) 10.5 minutes after it was asked, and more amazingly, (b) 15 seconds apart. (#TooSlow, @terdon! 😉)
– FeRD
yesterday
I'd just like to point out that both answers on this question came in: (a) 10.5 minutes after it was asked, and more amazingly, (b) 15 seconds apart. (#TooSlow, @terdon! 😉)
– FeRD
yesterday
I'd just like to point out that both answers on this question came in: (a) 10.5 minutes after it was asked, and more amazingly, (b) 15 seconds apart. (#TooSlow, @terdon! 😉)
– FeRD
yesterday
add a comment |
fdonadon is a new contributor. Be nice, and check out our Code of Conduct.
fdonadon is a new contributor. Be nice, and check out our Code of Conduct.
fdonadon is a new contributor. Be nice, and check out our Code of Conduct.
fdonadon is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f486818%2fhow-to-break-line-after-matching-case-but-needs-to-go-back-a-couple-of-character%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown