Concatenate multiple files but include filename as section headers

前端 未结 20 1660
粉色の甜心
粉色の甜心 2020-12-12 09:08

I would like to concatenate a number of text files into one large file in terminal. I know I can do this using the cat command. However, I would like the filename of each fi

20条回答
  •  死守一世寂寞
    2020-12-12 09:26

    If you like colors, try this:

    for i in *; do echo; echo $'\e[33;1m'$i$'\e[0m'; cat $i; done | less -R
    

    or:

    tail -n +1 * | grep -e $ -e '==.*'
    

    or: (with package 'multitail' installed)

    multitail *
    

提交回复
热议问题