news Command

Purpose

Writes system news items to standard output.

Syntax

news-a -n -sItem ... 

Description

The news command writes system news items to standard output. This command keeps you informed of news concerning the system. Each news item is contained in a separate file in the /var/news directory. Most users run the news command followed by the -n flag each time they log in by including it in their $HOME/.profile file or in the system's /etc/profile file. Any user having write permission to this directory can create a news item. It is not necessary to have read permission to create a news item.

If you run the news command without any flags, it displays every current file in the /var/news file, showing the most recent first. This command, used with the -a flag, displays all news items. If you specify the -n flag, only the names of the unread news items are displayed. Using the -s flag displays the number of unread news items. You can also use the Item parameter to specify the files that you want displayed.

Each file is preceded by an appropriate header. To avoid reporting old news, the news command stores a currency time. The news command considers your currency time to be the date the $HOME/.news_time file was last modified. Each time you read the news, the modification time of this file changes to that of the reading. Only news item files posted after this time are considered current.

Pressing the Interrupt (Ctrl-C) key sequence during the display of a news item stops the display of that item and starts the next. Pressing the Ctrl-C key sequence again ends the news command.

Note: News items can contain multibyte characters.

Flags

Item Description
-a Displays all news items, regardless of the currency time. The currency time does not change.
-n Reports the names of current news items without displaying their contents. The currency time does not change.
-s Reports the number of current news items without displaying their names or contents. The currency time does not change.

Examples

  1. To display the items that have been posted since you last read the news, enter:
    news
  2. To display all the news items, enter:

    news  -a pg

    All of the news items display a page at a time (| pg), regardless of whether you have read them yet.
  3. To list the names of the news items that you have not read yet, enter:

    news  -n

    Each name is a file in the /var/news directory.
  4. To display specific news items, enter:
    news newusers services
    This command sequence displays news about newusers and services, which are names listed by the news  -n command.
  5. To display the number of news items that you have not yet read, enter:

    news  -s

  6. To post news for everyone to read, enter:

    cp schedule /var/news

    This copies the schedule file into the system /var/news directory to create the /var/news/schedule file. To do this, you must have write permission to the /var/news directory.

Files

Item Description
/usr/bin/news Contains the news command.
/etc/profile Contains the system profile.
/var/news Contains system news item files.
$HOME/.news_time Indicates the date the news command was last invoked.