I process different binary data. Mostly, these are signed 16-bit streams. With hexdump, it looks like:
...
2150 -191 -262 15 -344 -883 -820 -1038 -780
-1234 -1406 -693 131 433 396 241 600 1280
...
I would like to see only those elements of a data stream, which are greater than or less than some threshold (data is binary signed 16-bit). It could look like:
cat data.pcm | $($here_some_filtering) 2100 -2100
where output must give me only elements which are greater than 2100 and less than -2100. Is there any simple command-line method how to do it?
$ cat pcm
2150 -191 -262 15 -344 -883 -820 -1038 -780
-1234 -1406 -693 131 433 396 241 600 1280
$ for num in $(< pcm); do ((num > 2100 || num < -2100)) && echo $num; done
2150