Adding words (tags) to a file [duplicate]
This question already has an answer here:
Insert line after first match using sed
6 answers
I want to add the words "Getting started" to two markdown files (so the extension is .md). They are named:
* installing-disqus.md
* installing-google-analytics.md
I would like to populate that word right after the line "Tags: " so the outcome would be "Tags: Getting started"
In Bash, what command would I write. I am thinking it would look something like this:
echo "Getting started" >> *installing* *Tags:*
bash echo
marked as duplicate by shellter
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 10 '18 at 23:09
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Insert line after first match using sed
6 answers
I want to add the words "Getting started" to two markdown files (so the extension is .md). They are named:
* installing-disqus.md
* installing-google-analytics.md
I would like to populate that word right after the line "Tags: " so the outcome would be "Tags: Getting started"
In Bash, what command would I write. I am thinking it would look something like this:
echo "Getting started" >> *installing* *Tags:*
bash echo
marked as duplicate by shellter
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 10 '18 at 23:09
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Hint: try usingsed
.
– user202729
Nov 10 '18 at 16:22
How is this related to keywords?
– user202729
Nov 10 '18 at 16:22
add a comment |
This question already has an answer here:
Insert line after first match using sed
6 answers
I want to add the words "Getting started" to two markdown files (so the extension is .md). They are named:
* installing-disqus.md
* installing-google-analytics.md
I would like to populate that word right after the line "Tags: " so the outcome would be "Tags: Getting started"
In Bash, what command would I write. I am thinking it would look something like this:
echo "Getting started" >> *installing* *Tags:*
bash echo
This question already has an answer here:
Insert line after first match using sed
6 answers
I want to add the words "Getting started" to two markdown files (so the extension is .md). They are named:
* installing-disqus.md
* installing-google-analytics.md
I would like to populate that word right after the line "Tags: " so the outcome would be "Tags: Getting started"
In Bash, what command would I write. I am thinking it would look something like this:
echo "Getting started" >> *installing* *Tags:*
This question already has an answer here:
Insert line after first match using sed
6 answers
bash echo
bash echo
edited Nov 10 '18 at 16:23
jimmytt
asked Nov 10 '18 at 16:18
jimmyttjimmytt
19829
19829
marked as duplicate by shellter
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 10 '18 at 23:09
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by shellter
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 10 '18 at 23:09
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Hint: try usingsed
.
– user202729
Nov 10 '18 at 16:22
How is this related to keywords?
– user202729
Nov 10 '18 at 16:22
add a comment |
Hint: try usingsed
.
– user202729
Nov 10 '18 at 16:22
How is this related to keywords?
– user202729
Nov 10 '18 at 16:22
Hint: try using
sed
.– user202729
Nov 10 '18 at 16:22
Hint: try using
sed
.– user202729
Nov 10 '18 at 16:22
How is this related to keywords?
– user202729
Nov 10 '18 at 16:22
How is this related to keywords?
– user202729
Nov 10 '18 at 16:22
add a comment |
1 Answer
1
active
oldest
votes
You could use sed to do a find and replace. Since you want the words added after Tags: (assumming there is only one such line) you could run:
sed -i “s/Tags:/Tags:<your text here>/g” <filename>
-i means that it will do the changes in the file
s/ means it will do a substitution
/
/g do this substitution in the whole file
This is headed in the right direction. How would I do it with two files Andrei? Both files start with "installing" and and in ".md" - "installing-disqus.md" and "installing-google-analytics.md"
– jimmytt
Nov 10 '18 at 16:32
You can use the wildcard operator “*” but better yet read this answer stackoverflow.com/a/10446276/10632970 .
– Andrei Dumitrescu-Tudor
Nov 10 '18 at 16:35
I am not sure what to do about the error message I got. Here is my attempt: sed -i "s/Tags:/Tags: Getting started/g" installing
– jimmytt
Nov 10 '18 at 16:39
Here is my error: sed: 1: "installing-disqus.md": command i expects followed by text
– jimmytt
Nov 10 '18 at 16:40
Can you tell me what environment your are using? I tried this command on Ubuntu 18.10 and it worked.
– Andrei Dumitrescu-Tudor
Nov 10 '18 at 16:45
|
show 2 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You could use sed to do a find and replace. Since you want the words added after Tags: (assumming there is only one such line) you could run:
sed -i “s/Tags:/Tags:<your text here>/g” <filename>
-i means that it will do the changes in the file
s/ means it will do a substitution
/
/g do this substitution in the whole file
This is headed in the right direction. How would I do it with two files Andrei? Both files start with "installing" and and in ".md" - "installing-disqus.md" and "installing-google-analytics.md"
– jimmytt
Nov 10 '18 at 16:32
You can use the wildcard operator “*” but better yet read this answer stackoverflow.com/a/10446276/10632970 .
– Andrei Dumitrescu-Tudor
Nov 10 '18 at 16:35
I am not sure what to do about the error message I got. Here is my attempt: sed -i "s/Tags:/Tags: Getting started/g" installing
– jimmytt
Nov 10 '18 at 16:39
Here is my error: sed: 1: "installing-disqus.md": command i expects followed by text
– jimmytt
Nov 10 '18 at 16:40
Can you tell me what environment your are using? I tried this command on Ubuntu 18.10 and it worked.
– Andrei Dumitrescu-Tudor
Nov 10 '18 at 16:45
|
show 2 more comments
You could use sed to do a find and replace. Since you want the words added after Tags: (assumming there is only one such line) you could run:
sed -i “s/Tags:/Tags:<your text here>/g” <filename>
-i means that it will do the changes in the file
s/ means it will do a substitution
/
/g do this substitution in the whole file
This is headed in the right direction. How would I do it with two files Andrei? Both files start with "installing" and and in ".md" - "installing-disqus.md" and "installing-google-analytics.md"
– jimmytt
Nov 10 '18 at 16:32
You can use the wildcard operator “*” but better yet read this answer stackoverflow.com/a/10446276/10632970 .
– Andrei Dumitrescu-Tudor
Nov 10 '18 at 16:35
I am not sure what to do about the error message I got. Here is my attempt: sed -i "s/Tags:/Tags: Getting started/g" installing
– jimmytt
Nov 10 '18 at 16:39
Here is my error: sed: 1: "installing-disqus.md": command i expects followed by text
– jimmytt
Nov 10 '18 at 16:40
Can you tell me what environment your are using? I tried this command on Ubuntu 18.10 and it worked.
– Andrei Dumitrescu-Tudor
Nov 10 '18 at 16:45
|
show 2 more comments
You could use sed to do a find and replace. Since you want the words added after Tags: (assumming there is only one such line) you could run:
sed -i “s/Tags:/Tags:<your text here>/g” <filename>
-i means that it will do the changes in the file
s/ means it will do a substitution
/
/g do this substitution in the whole file
You could use sed to do a find and replace. Since you want the words added after Tags: (assumming there is only one such line) you could run:
sed -i “s/Tags:/Tags:<your text here>/g” <filename>
-i means that it will do the changes in the file
s/ means it will do a substitution
/
/g do this substitution in the whole file
answered Nov 10 '18 at 16:28
Andrei Dumitrescu-TudorAndrei Dumitrescu-Tudor
19719
19719
This is headed in the right direction. How would I do it with two files Andrei? Both files start with "installing" and and in ".md" - "installing-disqus.md" and "installing-google-analytics.md"
– jimmytt
Nov 10 '18 at 16:32
You can use the wildcard operator “*” but better yet read this answer stackoverflow.com/a/10446276/10632970 .
– Andrei Dumitrescu-Tudor
Nov 10 '18 at 16:35
I am not sure what to do about the error message I got. Here is my attempt: sed -i "s/Tags:/Tags: Getting started/g" installing
– jimmytt
Nov 10 '18 at 16:39
Here is my error: sed: 1: "installing-disqus.md": command i expects followed by text
– jimmytt
Nov 10 '18 at 16:40
Can you tell me what environment your are using? I tried this command on Ubuntu 18.10 and it worked.
– Andrei Dumitrescu-Tudor
Nov 10 '18 at 16:45
|
show 2 more comments
This is headed in the right direction. How would I do it with two files Andrei? Both files start with "installing" and and in ".md" - "installing-disqus.md" and "installing-google-analytics.md"
– jimmytt
Nov 10 '18 at 16:32
You can use the wildcard operator “*” but better yet read this answer stackoverflow.com/a/10446276/10632970 .
– Andrei Dumitrescu-Tudor
Nov 10 '18 at 16:35
I am not sure what to do about the error message I got. Here is my attempt: sed -i "s/Tags:/Tags: Getting started/g" installing
– jimmytt
Nov 10 '18 at 16:39
Here is my error: sed: 1: "installing-disqus.md": command i expects followed by text
– jimmytt
Nov 10 '18 at 16:40
Can you tell me what environment your are using? I tried this command on Ubuntu 18.10 and it worked.
– Andrei Dumitrescu-Tudor
Nov 10 '18 at 16:45
This is headed in the right direction. How would I do it with two files Andrei? Both files start with "installing" and and in ".md" - "installing-disqus.md" and "installing-google-analytics.md"
– jimmytt
Nov 10 '18 at 16:32
This is headed in the right direction. How would I do it with two files Andrei? Both files start with "installing" and and in ".md" - "installing-disqus.md" and "installing-google-analytics.md"
– jimmytt
Nov 10 '18 at 16:32
You can use the wildcard operator “*” but better yet read this answer stackoverflow.com/a/10446276/10632970 .
– Andrei Dumitrescu-Tudor
Nov 10 '18 at 16:35
You can use the wildcard operator “*” but better yet read this answer stackoverflow.com/a/10446276/10632970 .
– Andrei Dumitrescu-Tudor
Nov 10 '18 at 16:35
I am not sure what to do about the error message I got. Here is my attempt: sed -i "s/Tags:/Tags: Getting started/g" installing
– jimmytt
Nov 10 '18 at 16:39
I am not sure what to do about the error message I got. Here is my attempt: sed -i "s/Tags:/Tags: Getting started/g" installing
– jimmytt
Nov 10 '18 at 16:39
Here is my error: sed: 1: "installing-disqus.md": command i expects followed by text
– jimmytt
Nov 10 '18 at 16:40
Here is my error: sed: 1: "installing-disqus.md": command i expects followed by text
– jimmytt
Nov 10 '18 at 16:40
Can you tell me what environment your are using? I tried this command on Ubuntu 18.10 and it worked.
– Andrei Dumitrescu-Tudor
Nov 10 '18 at 16:45
Can you tell me what environment your are using? I tried this command on Ubuntu 18.10 and it worked.
– Andrei Dumitrescu-Tudor
Nov 10 '18 at 16:45
|
show 2 more comments
Hint: try using
sed
.– user202729
Nov 10 '18 at 16:22
How is this related to keywords?
– user202729
Nov 10 '18 at 16:22