Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Oct 2019 08:44:53 +0200
From:      Polytropon <freebsd@edvax.de>
To:        "Clay Daniels Jr." <clay.daniels.jr@gmail.com>
Cc:        Kurt Hackenberg <kh@panix.com>, "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   Re: How to pipe kldstat output to a file in console
Message-ID:  <20191024084453.d9ae9d70.freebsd@edvax.de>
In-Reply-To: <CAGLDxTXJGeWVgJwyT7QzC=EuDLWXgcbHP=sqT52UXTjCssqsNg@mail.gmail.com>
References:  <CAGLDxTXUBgzP3ZRQXzj1w8bJpS%2BWEOyKkpBi7argMz5-MiegfQ@mail.gmail.com> <94a6b756-27bf-0363-b6f2-c711c33ab2c2@panix.com> <CAGLDxTXJGeWVgJwyT7QzC=EuDLWXgcbHP=sqT52UXTjCssqsNg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 23 Oct 2019 21:00:07 -0500, Clay Daniels Jr. wrote:
> Bingo!
> 
> create /root/kldstat_file with vi
> #kldstat -v >  /root/kldstat_file
> It's all there!

There is no no need to create the file beforehand. The > redirection
will do one of the following automatically:

	a) file not there ---> file will be created

	b) file there ---> file content will be overwritten

So a command like

	# kldstat -v > /root/kldstat.txt

will work no matter if the output file is already there or not.
This is the shell's default behaviour.

Sidenote:

If you want to append to a file, use >> instead of >.

Sidenote 2:

The easiest way to create an (empty) file is to use the "touch"
program, for example if you want to add the output of several
commands to a file:

	# touch /root/stuff.txt
	# ls / >> /root/stuff.txt
	# kldstat -v >> /root/stuff.txt
	# dmesg >> /root/stuff.txt

Sidenote 3:

In case you want to record a whole terminal session, including
commands and their outputs, use the "script" program:

	# script /root/session.txt
	. . . your commands here . . .
	# exit

This is very convenient if you want to document the command _and_
their outputs.



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20191024084453.d9ae9d70.freebsd>