[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 367
  • Last Modified:

Can we create custom file descriptor?

Hello, I learn that there are three file descriptor in bash as 0 (stdin) 1(stdin) 2(stderr). Here I would like to know if we can create our own file descriptor say 4 and 5? is it possible? Thanks!
0
beer9
Asked:
beer9
  • 2
1 Solution
 
Garry GlendownConsulting and Network/Security SpecialistCommented:
Simple, just use the "exec" command, e.g.

exec <4 somefile
exec >5 someotherfile
[..]
echo >5 Testoutput
read <&4

Open in new window

0
 
Garry GlendownConsulting and Network/Security SpecialistCommented:
sry, still half asleep I guess ;)

exec 4< somefile
exec 5> someotherfile
exec 6<> fileforreadwrite
[..]
echo >&5 Testoutput

Open in new window

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now