-1

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

2
  • 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. Commented Mar 1, 2019 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 Commented Mar 1, 2019 at 14:30

1 Answer 1

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.