help-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Write to and read from file descriptors in awk - awk: cannot open "/dev/


From: Ahmad Ismail
Subject: Write to and read from file descriptors in awk - awk: cannot open "/dev/fd/10" for output (No such file or directory)
Date: Sat, 29 Jul 2023 11:56:02 +0600

The data source (data.adoc) looks like:

Box Beast Base
> Bravo Beast Base
> Brazil Beast Base
> Bronx Beast Base


I have a filter (`./filter`) like:

#!/bin/bash

while
> read line
> do
> echo $line | tr "B" "b"
> done


The following client using coproc works:

 #!/usr/bin/env bash
> coproc ./filter

exec 10>&"${COPROC[1]}"
> exec 11<&"${COPROC[0]}"
> while IFS= read -r line || [ -n "$line" ]; do
>     echo "$line" >&10
>     read -r result <&11
>     echo "${result}"
> done < <(cat data.adoc)


But when I try to use awk replacing the while loop like:

awk '{ print $0 > "/dev/fd/10"
>     getline result < "/dev/fd/11"
>     print result }' data.adoc


It throws error:

> awk: cannot open "/dev/fd/10" for output (No such file or directory)


*Thanks and Best Regards,Ahmad Ismail*


reply via email to

[Prev in Thread] Current Thread [Next in Thread]