On Thu, 25 Mar 2010, Michael Hagedorn wrote: > On 25.03.10 21:30, Peter Korsgaard wrote: > > > Is there an easy way to disregard lines that contain only control > > > characters or filter the text? > > Sure, just use sed on the output from the serial port. > Thanks a lot. I tried this: > > cat /dev/ttyUSB0 | sed "s/$(printf '\r')/foundHere/" > > and this > > cat /dev/ttyUSB0 | sed "s/$(printf '\x0D')/foundHere/" > > but it didn't work (output stayed the same). I tried it with some string that > appears in the message and that worked. > I wonder if the printf doe something to the '\r'.
sed isn't really the tool for this job, as its line handling tends to get in the way. Try `tr -d '\r'` instead: # echo $'\r\n' | hd 00000000 0d 0a 0a |...| 00000003 # echo $'\r\n' | tr -d '\r' | hd 00000000 0a 0a |..| 00000002 Actually, there may be a busybox bug in sed here, because when I try `sed 's/\r//'` with GNU sed (version 4.1.5) it works as expected: $ echo $'\r\n' | sed 's/\r//' | hd 00000000 0a 0a |..| 00000002 _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
