Pipe output to bash function

前端 未结 7 974
故里飘歌
故里飘歌 2020-11-29 21:11

I have as simple function in a bash script and I would like to pipe stdout to it as an input.

jc_hms(){
  printf \"$1\"
}

I\'d like to use

相关标签:
7条回答
  • 2020-11-29 21:47

    Hmmmm....

    songplaytime=`echo $songtime | awk '{print S1 }'`
    printstring="`jc_hms $songplaytime`"  #store resulting string in printstring
    

    if you're calling awk anyway, why not use it?

    printstring=`TZ=UTC gawk -vT=$songplaytime 'BEGIN{print strftime("%T",T)}'`
    

    I'm assuming you're using Gnu's Awk, which is the best one and also free; this will work in common linux distros which aren't necessarily using the most recent gawk. The most recent versions of gawk will let you specify UTC as a third parameter to the strftime() function.

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