LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-19-2006, 03:28 PM   #1
Thinking
Member
 
Registered: Oct 2003
Posts: 249

Rep: Reputation: 30
bash: create a descriptor reading/writing from/to different files?


example:
echo file1 > file1
echo file2 > file2

if i do now:
exec 6<> file1

i have a descriptor 6 opened for reading and writing from/to file1
so it will read "file1"

but i want something like this
exec 6< file1 6>file2

i need ONE descriptor which reads from a file if something is read from the descriptor and writes to another file if something is written to the descriptor

is there a wait to do this?
it would be perfect if it works only trough bash i/o redirection

if it doesn't work, it would be interesting to know why
thx@ll

btw:
for reproduction this seems ok
echo 1234567890 > File # Write string to "File".
exec 3<> File # Open "File" and assign fd 3 to it. (<< this is what i want to replace)
read -n 4 <&3 # Read only 4 characters.
echo -n . >&3 # Write a decimal point there.
exec 3>&- # Close fd 3.
cat File # ==> 1234.67890
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH script Ė reading and writing variables to a separate file morrolan Programming 10 09-20-2005 07:45 AM
Reading and writing to files not working proporly realos Programming 4 08-05-2005 08:16 AM
reading / writing OpenOffice files. G™utama Programming 1 11-04-2003 06:46 AM
How to set timeout value when reading from a file descriptor. George2 Programming 7 10-26-2003 01:15 AM
Linksys WPC11 - Error -110 writing Tx descriptor to BAP edoope Linux - Networking 4 02-03-2003 03:14 AM


All times are GMT -5. The time now is 07:34 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration