bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Wishlist] add option to cat to force final newline


From: Bob Proulx
Subject: Re: [Wishlist] add option to cat to force final newline
Date: Tue, 25 Oct 2005 12:56:48 -0600
User-agent: Mutt/1.5.9i

Norbert Kiesel wrote:
> cat of a file without a '\n' as the last character results in the last
> line not shown in most shells (as it's overwritten with the shell
> prompt).  I wonder if a patch for an option like --force-newline or so
> would be accepted, which would print a final newline if the last
> character is not one.  Or is there already a way to get that behavior?

Thanks for filing that wishlist with the mailing list.  But let me
kindly disagree.

The cat command is not truly a screen lister program.  The cat command
concatenates files.  We only use it for a screen lister sometimes
because we know that the file is small and we just want to splat it to
the screen.  There are really too many options already to a simple
command like cat.

For a real screen lister program you should use more(1), less(1), or
even most(1).  That is where all of those features such as adding a
newline to the end of files and such belong.

Besides, you can always run an echo after the cat command.

  cat somefilewithoutnewline ; echo

Such as:

  $ cat <(printf "hello\nthere")
  hello
  there$

  $ cat <(printf "hello\nthere") ; echo
  hello
  there
  $

Another besides, why would you be cat'ing a file to your terminal that
does not contain a newline?  It is effectively binary data at that
point.  Instead, put a newline in the file.  :-) Plain text files
should always end with a newline.  So the problem is really there.

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]