Sponsored Content
Full Discussion: Purpose of <>
Top Forums UNIX for Dummies Questions & Answers Purpose of <> Post 302607368 by drl on Wednesday 14th of March 2012 08:43:07 AM
Old 03-14-2012
Hi.

The purpose is as noted, opens for both input and output:
Code:
Opening File Descriptors for Reading and Writing
The redirection operator

[n]<>word

causes the file whose name is the expansion of word to be opened
for both reading and writing on file descriptor n, or on file
descriptor 0 if n is not specified.  If the file does not exist,
it is created. 

-- excerpt ffom man bash

I don't recall an instance when I needed such a construct, however, it is syntactically acceptable:
Code:
#!/usr/bin/env bash

# @(#) s1	Demonstrate <> re-direction operator.

pe() { for _i;do printf "%s" "$_i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }
db() { ( printf " db, ";for _i;do printf "%s" "$_i";done;printf "\n" ) >&2 ; }
db() { : ; }
C=$HOME/bin/context && [ -f $C ] && . $C

rm -f f
pl " Create descriptor 4 and file f, show file:"
exec 4<>f
ls -lgG f

pl " Write to f:"
echo hi >f
ls -lgG f

pl " Read from f:"
cat <f

exit 0

producing:
Code:
% ./s1

Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution        : Debian GNU/Linux 5.0.8 (lenny) 
bash GNU bash 3.2.39

-----
 Create descriptor 4 and file f, show file:
-rw-r--r-- 1 0 Mar 14 12:43 f

-----
 Write to f:
-rw-r--r-- 1 3 Mar 14 12:43 f

-----
 Read from f:
hi

It may be useful for writing on stdin, but I don't see the point of that.

Perhaps someone will describe a useful situation ... cheers, drl

( edit 1: corrected for exec mis-typed as echo )
( edit 2: misspelling )

Last edited by drl; 03-14-2012 at 05:50 PM..
This User Gave Thanks to drl For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Purpose of lint in UNIX

Can Any One let me know abut the use on "lint" in UNIX...... (1 Reply)
Discussion started by: kumar_saurabh
1 Replies

2. UNIX for Dummies Questions & Answers

whats the purpose of the following script?

whats the purpose of the following script? who could run it? To what is the script refering that exceeds 75%? The mailbox? What does sed 's/%//' do? (1 Reply)
Discussion started by: vrn
1 Replies

3. Shell Programming and Scripting

Purpose of 2>&1 in the command

Can any body kindly tell me what is the purpose of 2>&1 in the following commands. nohup ./append_import.sh 1 > import1.out 2>&1 < /dev/null & nohup ./append_import.sh 2 > import2.out 2>&1 < /dev/null & (1 Reply)
Discussion started by: mmunir
1 Replies

4. Filesystems, Disks and Memory

Purpose of dsi log

Hi Please explain what is dsi log? Does it stores details related to File systems? (0 Replies)
Discussion started by: student2010
0 Replies

5. UNIX for Dummies Questions & Answers

What is the purpose of 2 >&1 in crontab?

while we editing the cron at the end of the cron what is the purpose of giving 2 >&1 (4 Replies)
Discussion started by: senmak
4 Replies

6. UNIX for Dummies Questions & Answers

Purpose of /etc/cron.d

What is the purpose of /etc/cron.d? (3 Replies)
Discussion started by: proactiveaditya
3 Replies

7. UNIX for Advanced & Expert Users

Purpose of inv

Hi All Can anybody tell me what is the purpose of inv in the below command. ftp -inv $RFTPSERVER /temp/te.txt << EOF and << its stands for what.. Thanks (1 Reply)
Discussion started by: raju4u
1 Replies

8. UNIX for Dummies Questions & Answers

exact purpose of links

please explain what is the exact purpose of hard link and soft link which is best one thanks in advance regards, surendra thota (3 Replies)
Discussion started by: tsurendra
3 Replies

9. Solaris

What is the purpose of Bind on Solaris 10?

I'm new to Solaris and Linux and I was wondering if someone could explain to me in simple terms what the process Bind is on Solaris 10? Thanks, in advance. (6 Replies)
Discussion started by: jastanle84
6 Replies

10. AIX

What is the Purpose of /dev/ipldevice?

Hi, Anyone, please explain the purpose of /dev/ipldevice in AIX .. it would be a problem if there is no /dev/ipldevice while booting. Regards, Siva (1 Reply)
Discussion started by: ksgnathan
1 Replies
GENERATELORE(1) 														   GENERATELORE(1)

NAME
lore - convert documentations formats SYNOPSIS
lore [-l linkrel] [-d docsdir] [-i input] [-o output] [--config attribute[=value] [...]] [-p] [file [...]] lore --help DESCRIPTION
The --help prints out a usage message to standard output. -p, --plain Use non-flashy progress bar - one file per line. -n, --null Do not report progress at all. -N, --number Add chapter/section numbers to section headings. -l, --linkrel Where non-document links should be relative to. -d, --docsdir Where to look for .html files if no files are given. -e, --inputext <extension> The extension that your Lore input files have (default: .xhtml) -i, --input Input format. New input formats can be dynamically registered. Lore itself comes with "lore" (the standard format), "mlore" (allows LaTeX equations) and "man" (man page format). If the input format is not registered as a plugin, a module of the named input will be searched. For example, --i twisted.lore.default is equivalent to using the default Lore input. -o, --output Output format. Available output formats depend on the input. For the core formats, lore and mlore support html, latex and lint, while man allows lore. -x, --index <filename> The base filename you want to give your index file. -b, --book <filename> The book file to generate a book from. --prefixurl <prefix> The prefix to stick on to relative links; only useful when processing directories. --version Display version information and exit. --config Add input/output-specific information. HTML output allows for 'ext=<extension>', output allows for 'section' or 'chapter' in Lore, and nothing in Math-Lore. Lore output allows for 'ext=<extension>'. Lint output allows nothing. Note that disallowed --config options are merely ignored, and do not cause errors. DESCRIPTION
If no files are given, all *.html documents in docsdir are processed. AUTHOR
Written by Moshe Zadka REPORTING BUGS
To report a bug, visit http://twistedmatrix.com/bugs/ COPYRIGHT
Copyright (C) 2003-2008 Twisted Matrix Laboratories. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. October 2002 GENERATELORE(1)
All times are GMT -4. The time now is 12:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy