Pushparaj
Pushparaj

Reputation: 1059

Using file descriptor with here document

I want to open here document into a file descriptor with number 3. Which later I copy into standard input of cat command. But this doesn't work. See below

#!/bin/bash

cat 3<<222889 
I am reading
a string into 
file descriptor 3 which is copied to standrad input
222889
0<&3

Upvotes: 1

Views: 426

Answers (1)

iBug
iBug

Reputation: 37227

Place both redirectors on the same line:

cat 3<<222889 0<&3
I am reading
a string into 
file descriptor 3 which is copied to standrad input
222889

Then cat just outputs everything in the here document, plain.

Upvotes: 5

Related Questions