I have seen this technique before, but I don’t know what it called and forgot the exact syntax. Let's say I need to transfer the file to the program, for example: command <Enter file. However, I want to directly pass these lines of the input file to the command without an intermediate input file. It looks something like this, but it does not work:
command < $(file-line1; file-line2; file-line3)
Can someone tell me what this is called and how to do it?
It is called Process Substitution
Process Substitution
command < <(printf "%s\n" "file-line1" "file-line2" "file-line3")
, command , , /dev/fd/XX, "XX" - . , ( ), , printf.
command
/dev/fd/XX
printf
Herestring.
command <<< $'line 1\nline 2\nline 3\n'
heredoc.
command << EOF line 1 line 2 line 3 EOF
I think you mean "here is the document." Like this
#!/bin/sh cat <<EOF This is the lines. EOF
What about:
cat myfile.txt | head -n3 | command