Bash script: save stream from Serial Port (/dev/ttyUSB0) to file until a specific input (e.g. eof) appears

前端 未结 1 2047
不知归路
不知归路 2021-01-05 13:02

I need a bash script to read the data stream from a Serial Port (RS232 to USB adapter - Port: /dev/ttyUSB0). The data should be stored line by line in a file until a specifi

1条回答
  •  天命终不由人
    2021-01-05 14:02

    Try awk(1):

    awk `
    /EOF/ {exit;} 
     {print;}` < /dev/ttyUSB0 > file.txt
    

    This stops when it sees the line EOF and prints everything else to file.txt

    0 讨论(0)
提交回复
热议问题