0

I am looking to write the output of

cat /var/log/dpkg.log

to a file rather than viewing on the screen.

I have tried

cat /var/log/dpkg.log | file.txt

without any success.

Ultimately I want this command and

dmesg -T

to run automatically from a batch from a usb.

The usb has the "ID" of 0782:5551. Is it possible to get the "file.txt" (with the date and time included in filename) to be written to that same USB drive via it's "ID" since it could any "device' depending on its order?

The purpose of this is for a project to ultimately compare the file based on dates.

рüффп
  • 1,707

1 Answers1

1

| is used to pass the output to another command. > re-directs it to a file.

You need >.

  • 2
    Indeed. Also, one usually writes files to the mounted filesystem, not to the device file itself. So it would be dmesg -T > /media/mounpoint/$(date +%Y%m%d%a%H%M).log. Auto-generated mount-points rely on partition IDs or labels and thus are usually stable. – Hermann Nov 10 '18 at 13:48