Creating file and passing argument to a command

Hi All,

I am having command to run which will take argument as input file. Right now we are creating the input file by cat and executing the command

 ftptransfer -i input file 
cat >input file
file1
file2
cntrl +d

Is there a way I can do that in a single command like

ftptransfer -i  cat > file1 file2 

Thanks
Arun

I don't know if you utility ftptransfer can process stdin. If so you could use a "here document" .

For example (I do not know filetransfer , so it is just a guess if it works that way, you would need to check the manual):

ftptransfer << EOF
file1
file2
EOF

If you are using modern bash, ksh93 or zsh you could also try process substitution, something like:

ftptransfer -i <(printf "%s\n" file1 file2)

or turn a here document in to a "file"

ftptransfer -i <(cat << EOF
file1
file2
EOF
)

or an example using a here-string

files="file1
file2"

ftptransfer -i <(cat <<< "$files")
1 Like