How to make cat start a new line

前端 未结 6 565
情话喂你
情话喂你 2021-01-18 02:24

I have four files:

one_file.txt

abc | def

two_file.txt

ghi | jkl

three_file.txt

m         


        
6条回答
  •  星月不相逢
    2021-01-18 02:47

    You can loop over each file and do a check to see if the last line ends in a new line, outputting one if it doesn't.

    for file in *file.txt; do
        cat "$file"
        [[ $(tail -c 1 "$file") == "" ]] || echo
    done > full_set.txt
    

提交回复
热议问题