This is how I do it. I just checked it in Cygwin. I hope it works on Linux as well. Put this in a file, for example mycommand :
#!/usr/bin/awk -f BEGIN { FS="-"; max = 0; maxString = ""; } { num = $3 + 0; # convert string to int if (num > max) { max = num; split($3, arr, "'"); maxString = arr[2]; } } END { print maxString; }
Then make the executable ( chmod 755 mycommand ). Now you can transfer whatever you want by entering, for example, cat somefile | ./mycommand cat somefile | ./mycommand .
source share