Hi,
Need some help with creating a file from input steam. Meaning from following command myfunc should be able to store the input stream to a file.
echo a b c | myfunc
The file thus created should have -
a
b
c
Here's what I've tried in myfunc() but didn't help -
myfunc() { cat &0 > /tmp/1 }
Probably because that's not valid syntax for a function, or redirection.
myfunc() {
cat > /tmp/$$
}
Try:
myfunc()
{
tr " " "\n" > /tmp/1
}
Great, thanks guys.
Also I was wondering if there's a way to check if the stream is empty or not?
Currently what I do it check the size of /tmp/$$ after I created it from the steam. Is there a better way of doing it?