How to modify this sed awk command so that the output goes to a file of choice?

前端 未结 3 1999
小鲜肉
小鲜肉 2021-01-23 15:48

I am using the last command from this SO answer https://stackoverflow.com/a/54818581/80353

cap()(cd /tmp;rm -f *.vtt;youtube-dl --skip-download --write-auto-sub          


        
3条回答
  •  自闭症患者
    2021-01-23 16:30

    Considering that you want to see output on screen as well as you want to save output into a output file too, if this is the case could you please try following.

    cap()(cd /tmp;rm -f *.vtt;youtube-dl --skip-download --write-auto-sub "$1";sed '1,/^$/d' *.vtt|sed 's/<[^>]*>//g'|awk -F. 'NR%8==1{printf"%s ",$1}NR%8==3'|tee -a "$2")
    

    OR in non-one liner form use:

    cap()(cd /tmp;rm -f *.vtt;youtube-dl --skip-download --write-auto-sub "$1";\
    sed '1,/^$/d' *.vtt|sed 's/<[^>]*>//g'|awk -F. 'NR%8==1{printf"%s ",$1}NR%8==3'\
    |tee -a "$2")
    

    Please make sure that you have provided complete path in your variable eg--> relative_or_absolute_path_of_text_or_markdown_file="/full/path/output_file.txt" etc just an example. I couldn't test it since I don't have mechanism for vtt files etc in my box.

    In case you don't want to print information on screen and simply want to save output into output file then as @oguz ismail's comment use only tee "$2" not tee -a "$2" as I shown above.

提交回复
热议问题