Remove ânâ string from end of certain lines
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
How do I remove the string "n" (not the newline character) from the end of only lines that begin with the string "///"? Thanks.
Example Input:
Some textn
/// Some commentn
Desired Output:
Some textn
/// Some comment
I've tried to use
sed -i 's/\n*$//' $1
But, it removes all of the trailing "n" strings.
sed
add a comment |Â
up vote
2
down vote
favorite
How do I remove the string "n" (not the newline character) from the end of only lines that begin with the string "///"? Thanks.
Example Input:
Some textn
/// Some commentn
Desired Output:
Some textn
/// Some comment
I've tried to use
sed -i 's/\n*$//' $1
But, it removes all of the trailing "n" strings.
sed
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
How do I remove the string "n" (not the newline character) from the end of only lines that begin with the string "///"? Thanks.
Example Input:
Some textn
/// Some commentn
Desired Output:
Some textn
/// Some comment
I've tried to use
sed -i 's/\n*$//' $1
But, it removes all of the trailing "n" strings.
sed
How do I remove the string "n" (not the newline character) from the end of only lines that begin with the string "///"? Thanks.
Example Input:
Some textn
/// Some commentn
Desired Output:
Some textn
/// Some comment
I've tried to use
sed -i 's/\n*$//' $1
But, it removes all of the trailing "n" strings.
sed
asked Jul 11 at 23:30
caleb_hendrix
133
133
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
Add a regex address specifier at the front - since your pattern has forward slashes, it's clearer if you use a different expression separator:
sed -i '%^///% s/\n$//' Input
Testing:
$ sed '%^///% s/\n$//' Input
Some textn
/// Some comment
If you prefer "leaning toothpicks"
sed -i '/^//// s/\n$//' Input
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Add a regex address specifier at the front - since your pattern has forward slashes, it's clearer if you use a different expression separator:
sed -i '%^///% s/\n$//' Input
Testing:
$ sed '%^///% s/\n$//' Input
Some textn
/// Some comment
If you prefer "leaning toothpicks"
sed -i '/^//// s/\n$//' Input
add a comment |Â
up vote
2
down vote
accepted
Add a regex address specifier at the front - since your pattern has forward slashes, it's clearer if you use a different expression separator:
sed -i '%^///% s/\n$//' Input
Testing:
$ sed '%^///% s/\n$//' Input
Some textn
/// Some comment
If you prefer "leaning toothpicks"
sed -i '/^//// s/\n$//' Input
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Add a regex address specifier at the front - since your pattern has forward slashes, it's clearer if you use a different expression separator:
sed -i '%^///% s/\n$//' Input
Testing:
$ sed '%^///% s/\n$//' Input
Some textn
/// Some comment
If you prefer "leaning toothpicks"
sed -i '/^//// s/\n$//' Input
Add a regex address specifier at the front - since your pattern has forward slashes, it's clearer if you use a different expression separator:
sed -i '%^///% s/\n$//' Input
Testing:
$ sed '%^///% s/\n$//' Input
Some textn
/// Some comment
If you prefer "leaning toothpicks"
sed -i '/^//// s/\n$//' Input
answered Jul 11 at 23:35
steeldriver
30.9k34877
30.9k34877
add a comment |Â
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f454796%2fremove-n-string-from-end-of-certain-lines%23new-answer', 'question_page');
);
Post as a guest
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
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
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