I often use a program called tty0tty, which creates a null modem using PTYs. Now I want to make it part of an automated process.When I start tty0tty it prints (/dev/pts/1) <=> (/dev/pts/2)Would it be possible to parse the output and use the matches as parameters to another program? So that the following lines could be automated:linux$ tty0tty &(/dev/pts/X) <=> (/dev/pts/Y)linux$ someprogram /dev/pts/X &linux$ microcom /dev/pts/Y
Matching several patterns on one line
bash;sed;grep
You can use sed and process substitution:read left right < <(tty0tty | head -n 1 | sed -e 's/[()<=>]//g' &)After that, $left is /dev/pts/X and right is /dev/pts/Y.This cheats a little - we just replace the characters (, ), <, =, and > with nothing, and then rely on the shell's word splitting after that.We pipe the tty0tty output into head so we only take the first (only) line of output and don't block forever. From there it goes into the sed command that does the replacement, then use the shell's read bultin to bind the shell variables left and right to the first and second words of the input we give it. We get that input from the <(...). <(...) runs ... in a subshell and connects its output to a pipe we can read from. We feed that pipe into read with the first <, so it gets /dev/pts/X  /dev/pts/Y and splits it into the two words we wanted.After this you could run someprogram $left and microcom $right as desired.