You are not logged in.
Pages: 1
Anyone else realized that nl's output isn't redirected?
For example
nl > file.txt
and
nl | cat -
fail to produce any output, while
cat file1.txt | nl > file2.txt
does work, so maybe it's because I pressed ^C (even though it works fine with cat)?
However, even weirder is
nl | head -2
which doesn't quit automatically after 2 lines like
cat - | head -2
would.
Any idea how to works around this?
Offline
nl counts the number of lines in a text file, if one is provided on the command line, otherwise it reads from standard input.
You should not press ^C in such a case, but ^D, to send an End of Transmission (EOT). Before you do that, nl will not count any lines.
You may want to read up on how shell redirection and stdin/stdout/stderr work, e.g. https://en.wikipedia.org/wiki/Redirection_(computing)
Offline
You need to send an EOF (Ctrl+d) to terminate the input, not an interrupt signal (Ctrl+c).
https://www.digitalocean.com/community/ … edirection
Alternatively use a HEREDOC.
http://tldp.org/LDP/abs/html/here-docs.html
EDIT: snaked by ayecat
Last edited by WorMzy (2017-10-02 13:28:07)
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
if you use the first or second command, but end input with ^D (EOT) rather than ^C (fire SIGINT), you will find it properly writes to the file.
I was ninja'd.
All the best,
-HG
Last edited by HalosGhost (2017-10-02 13:33:57)
Offline
Pages: 1