I
I
Inter Carpenter2017-02-12 21:58:44
linux
Inter Carpenter, 2017-02-12 21:58:44

How to stop command output through BASH?

Greetings
There is a program at the start of which, it starts writing to the terminal 2 lines every 10 seconds, pauses - an empty line.
How to output one result and terminate the program?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Saboteur, 2017-02-13
@saboteur_kiev

What is the team?
Option 1: look at the help for this command - a lot of commands provide exit options after displaying n results, for example ping, which by default writes until interrupted.
Option 2: run it in the background, pause for a few seconds and kill it, for example
mycommand &; sleep5; killall mycommand
Option 3: mycommand | head -<strings>

A
abcd0x00, 2017-02-13
@abcd0x00

[[email protected] ~]$ func() { while true; do echo a; echo b; sleep 5; done; }
[[email protected] ~]$ func | head -2
a
b
[[email protected] ~]$

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question