how to read a random line from 2 files and put them together

前端 未结 1 902
忘了有多久
忘了有多久 2021-01-23 14:00

so I tried shuf -n 1 filename in bash and it showed me a random line, but I want to be able to do this on my own website with 2 files and the outputs combined.

相关标签:
1条回答
  • 2021-01-23 14:41

    With paste, shuf and bash's process substitution:

    paste -d " " <(shuf -n 1 file1) <(shuf -n 1 file2)
    

    Output (example):

    one two three canada
    
    0 讨论(0)
提交回复
热议问题