{"id":6119,"date":"2022-12-20T18:57:56","date_gmt":"2022-12-20T21:57:56","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/read-mann\/"},"modified":"2022-12-20T18:57:56","modified_gmt":"2022-12-20T21:57:56","slug":"read-mann","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/read-mann\/","title":{"rendered":"read (mann)"},"content":{"rendered":"<h1 align=\"center\">read<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#USE WITH SERIAL PORTS\">USE WITH SERIAL PORTS<\/a><br \/> <a href=\"#EXAMPLE\">EXAMPLE<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#KEYWORDS\">KEYWORDS<\/a> <\/p>\n<hr>\n<p>______________________________________________________________________________<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">read \u2212 Read from a channel<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>read<\/b> ?<b>\u2212nonewline<\/b>? <i>channelId<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>read<\/b> <i>channelId numChars<\/i> ______________________________________________________________________________<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">In the first form, the <b>read<\/b> command reads all of the data from <i>channelId<\/i> up to the end of the file. If the <b>\u2212nonewline<\/b> switch is specified then the last character of the file is discarded if it is a newline. In the second form, the extra argument specifies how many characters to read. Exactly that many characters will be read and returned, unless there are fewer than <i>numChars<\/i> left in the file; in this case all the remaining characters are returned. If the channel is configured to use a multi-byte encoding, then the number of characters read may not be the same as the number of bytes read.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>ChannelId<\/i> must be an identifier for an open channel such as the Tcl standard input channel (<b>stdin<\/b>), the return value from an invocation of <b>open<\/b> or <b>socket<\/b>, or the result of a channel creation command provided by a Tcl extension. The channel must have been opened for input.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If <i>channelId<\/i> is in nonblocking mode, the command may not read as many characters as requested: once all available input has been read, the command will return the data that is available rather than blocking for more input. If the channel is configured to use a multi-byte encoding, then there may actually be some bytes remaining in the internal buffers that do not form a complete character. These bytes will not be returned until a complete character is available or end-of-file is reached. The <b>\u2212nonewline<\/b> switch is ignored if the command returns before reaching the end of the file.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Read<\/b> translates end-of-line sequences in the input into newline characters according to the <b>\u2212translation<\/b> option for the channel. See the <b>fconfigure<\/b> manual entry for a discussion on ways in which <b>fconfigure<\/b> will alter input.<\/p>\n<h2>USE WITH SERIAL PORTS <a name=\"USE WITH SERIAL PORTS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">For most applications a channel connected to a serial port should be configured to be nonblocking: <b>fconfigure<\/b> <i>channelId<\/i> <b>\u2212blocking<\/b> <i>0<\/i>. Then <b>read<\/b> behaves much like described above. Care must be taken when using <b>read<\/b> on blocking serial ports: <b><br \/> read<\/b> <i>channelId numChars<\/i><\/p>\n<p style=\"margin-left:22%;\">In this form <b>read<\/b> blocks until <i>numChars<\/i> have been received from the serial port.<\/p>\n<p style=\"margin-left:11%;\"><b>read<\/b> <i>channelId<\/i><\/p>\n<p style=\"margin-left:22%;\">In this form <b>read<\/b> blocks until the reception of the end-of-file character, see <b>fconfigure \u2212eofchar<\/b>. If there no end-of-file character has been configured for the channel, then <b>read<\/b> will block forever.<\/p>\n<h2>EXAMPLE <a name=\"EXAMPLE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This example code reads a file all at once, and splits it into a list, with each line in the file corresponding to an element in the list:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">set fl [open \/proc\/meminfo] <br \/> set data [<b>read<\/b> $fl] <br \/> close $fl <br \/> set lines [split $data n]<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">file(n), eof(n), fblocked(n), fconfigure(n), Tcl_StandardChannels(3)<\/p>\n<h2>KEYWORDS <a name=\"KEYWORDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">blocking, channel, end of line, end of file, nonblocking, read, translation, encoding<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  read \u2212 Read from a channel <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3783,1],"tags":[2635,2307],"class_list":["post-6119","post","type-post","status-publish","format-standard","hentry","category-n-comandos-tcl-tk","category-sin-categoria","tag-mann","tag-read"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=6119"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6119\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=6119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=6119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=6119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}