I've coded a script and am wondering about it's reliability / portability.#!/bin/bashthreadsPlease() {  ps -mo lwp,c -p $1 | sort -gk 2 | uniq -f 1 }THREAD_LINE=$( threadsPlease $1 | grep -v - | tail -1)THREAD10=$(echo $THREAD_LINE | awk '{print $1}')THREAD16=$(printf '%x\n' $THREAD10)JAVA_LINE=$(jstack $1 | grep $THREAD16)echo OS data (thread, CPU usage %):  $THREAD_LINEecho Java thread:  $JAVA_LINEScript displays system and Java thread data, given Java PID. Sample execution:./whichThreadIsIt.sh 6814OS data (thread, CPU usage %):  6838 3Java thread:  AWT-EventQueue-0 #19 prio=6 os_prio=0 tid=0x00007f50f4090800 nid=0x1ab6 waiting on condition [0x00007f510dfbb000]Q1: Aside from the obvious (jstack/java/awk/... is not available or not in path or input data given wrongly), when this will not work the intended way (Ubuntu/Debian)?Q2: It's easier to port a shell, than a shell-script, my friend likes to say. So, how much more effort this would need to work in Fedora / CentOS, Free BSD and Solaris? Am I wrong expecting it to run without troubles (assuming Bash present on those boxes)?
How reliable/portable are Nix built-ins/commands (echo, ps, sort, uniq) from Debian to other distros
debian;shell script;posix;portability