Disabling the Cat Command

Disabling the cat command

On Linux, you can use a sink() call to /dev/null(or to a temporary file on another OS, see ?tempfile) :

sink(file="/dev/null")
f()
sink()

Why does only one output of the 'cat' command come with a linebreak?

The rsyslogd.pid file probably doesn't end with a newline character (ASCII 0x0A).

You didn't mention how you opened the files, but, I suspect you used a text editor which will not display non-printable characters (like newline and backspace). Rather than using a text editor try looking at the raw file with the hexdump tool. Then compare the hex values against an ASCII table. I think you will find that the non-printable characters after the 599 and 636 are different.

hexdump -C rsyslogd.pid
hexdump -C acpid.pid

The following sequence of commands reproduces your output. The key is to use the -n flag for the echo command to create a file without a newline character at the end.

$ echo -n test > file_no_new_line.txt
$ echo test > file_with_new_line.txt
$ cat file_no_new_line.txt
test$ cat file_with_new_line.txt
test
$

Here is the output of hexdump for the two files shown in my example.

$ hexdump -C file_no_new_line.txt
00000000 74 65 73 74 |test|
00000004
$ hexdump -C file_with_new_line.txt
00000000 74 65 73 74 0a |test.|
00000005
$

The command output, in this case from cat, and the shell prompt ($) running into each other is also shell dependent. If the behavior can't be reproduce with the steps above try another shell (e.g. /bin/sh)

How to hide or disable in-function printed message

You can use capture.output with invisible

> invisible(capture.output(y <- ff(2)))
> y
[1] 4

or sink

> sink("file")
> y <- ff(2)
> sink()
> y
[1] 4

Disable progress indication in git command line

redirect stderr to cat. Unlike -q it doesn't suppress all output:

 /test/media/ffmpeg
$ git fetch 2>&1 | cat
From git://source.ffmpeg.org/ffmpeg
cc0e2ba..0bc3de1 master -> origin/master
58e212c..41216eb release/0.10 -> origin/release/0.10
929100a..69f724a release/0.11 -> origin/release/0.11
243396f..101e1b3 release/0.6 -> origin/release/0.6
1049328..cce6bdc release/0.7 -> origin/release/0.7
115efde..8925c44 release/0.8 -> origin/release/0.8
b6f5a54..320df1c release/0.9 -> origin/release/0.9
e28d960..a4c804d release/1.0 -> origin/release/1.0
b8eaf47..08dde75 release/1.1 -> origin/release/1.1
86d4d4b..89c917f release/1.2 -> origin/release/1.2
7e73760..b4552cc release/2.0 -> origin/release/2.0
69a283e..ac38860 release/2.1 -> origin/release/2.1
* [new tag] n0.10.11 -> n0.10.11
* [new tag] n2.0.3 -> n2.0.3
From git://source.ffmpeg.org/ffmpeg
* [new tag] n1.1.8 -> n1.1.8
* [new tag] n1.2.5 -> n1.2.5
* [new tag] n2.1.2 -> n2.1.2
* [new tag] n2.1.3 -> n2.1.3

How do I turn off echo in a terminal?

stty_orig=`stty -g`
stty -echo
echo 'hidden section'
stty $stty_orig


Related Topics



Leave a reply



Submit