How can I use grep in a loop and add new line of text each time to the same file?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I am trying to use grep in a loop and extract data from many files and then save them in a text file. Currently when I write
grep sth > test.txt
It writes it in the file test.txt, but when I run the same code it will not add the text to the end of the previously saved text, it overwrites it. What can I do?
shell-script shell grep
New contributor
add a comment |Â
up vote
0
down vote
favorite
I am trying to use grep in a loop and extract data from many files and then save them in a text file. Currently when I write
grep sth > test.txt
It writes it in the file test.txt, but when I run the same code it will not add the text to the end of the previously saved text, it overwrites it. What can I do?
shell-script shell grep
New contributor
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to use grep in a loop and extract data from many files and then save them in a text file. Currently when I write
grep sth > test.txt
It writes it in the file test.txt, but when I run the same code it will not add the text to the end of the previously saved text, it overwrites it. What can I do?
shell-script shell grep
New contributor
I am trying to use grep in a loop and extract data from many files and then save them in a text file. Currently when I write
grep sth > test.txt
It writes it in the file test.txt, but when I run the same code it will not add the text to the end of the previously saved text, it overwrites it. What can I do?
shell-script shell grep
shell-script shell grep
New contributor
New contributor
New contributor
asked 12 mins ago
emad1234
1
1
New contributor
New contributor
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
You need >>
>
overwrites the data in a file whereas >>
appends the data to the end of the file.
I'm going to assume that you have some foles that you are getting from
grep sth /path/to/files/* >> test.txt
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You need >>
>
overwrites the data in a file whereas >>
appends the data to the end of the file.
I'm going to assume that you have some foles that you are getting from
grep sth /path/to/files/* >> test.txt
add a comment |Â
up vote
0
down vote
You need >>
>
overwrites the data in a file whereas >>
appends the data to the end of the file.
I'm going to assume that you have some foles that you are getting from
grep sth /path/to/files/* >> test.txt
add a comment |Â
up vote
0
down vote
up vote
0
down vote
You need >>
>
overwrites the data in a file whereas >>
appends the data to the end of the file.
I'm going to assume that you have some foles that you are getting from
grep sth /path/to/files/* >> test.txt
You need >>
>
overwrites the data in a file whereas >>
appends the data to the end of the file.
I'm going to assume that you have some foles that you are getting from
grep sth /path/to/files/* >> test.txt
answered 4 mins ago
Nasir Riley
1,993139
1,993139
add a comment |Â
add a comment |Â
emad1234 is a new contributor. Be nice, and check out our Code of Conduct.
emad1234 is a new contributor. Be nice, and check out our Code of Conduct.
emad1234 is a new contributor. Be nice, and check out our Code of Conduct.
emad1234 is a new contributor. Be nice, and check out our Code of Conduct.
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%2f479679%2fhow-can-i-use-grep-in-a-loop-and-add-new-line-of-text-each-time-to-the-same-file%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