-1

This question already has an answer here:

I have a grep command like below

zgrep '123_ERROR' xyz.gz

I got lot of huge results where I cannot see top part.

So what is best way to see entire result

how to export results to a file

zgrep '123_ERROR' xyz.gz>>/home/test/testfile.txt

i used above command but i do not seem to have permission to create testfile.txt

how to create above file in one other server whose ip is say 111.1.111.111

marked as duplicate by RoVo, Rui F Ribeiro linux Mar 1 at 17:20

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.

  • Hi an welcome to StackExchange. Unfortunately, it is very unclear what you're asking. Please edit your question to show exactly what you're trying to do (input and expected output), and where you are stuck. Also, to see the 'complete' output, you can just pipe zgrep into less or more. – Panki Mar 1 at 14:22
  • I don't know why the IP would affect this. You've tried to write to a file /home/test/testfile.txt Unless your current user is called test you probably don't have access to do this. You can easily reference your own home directory with ~. Eg: zgrep '123_ERROR' xyz.gz ~/testfile.txt – Philip Couling Mar 1 at 14:30
0

If you wish to do that remotely you can do it this way:

ssh 111.1.111.111 zgrep '123_ERROR' xyz.gz | less

or

ssh 111.1.111.111 zgrep '123_ERROR' xyz.gz \| less

The first command greps results and sends back to you while less is invoced by your host.

The second command does everything on the remote server (the pipe is sent to the other end).

To be precise if you wish to store the output on your computer you could run:

ssh 111.1.111.111 zgrep '123_ERROR' xyz.gz >> local_file

Not the answer you're looking for? Browse other questions tagged or ask your own question.