add filename to beginning of file using find and sed

后端 未结 5 756
死守一世寂寞
死守一世寂寞 2021-01-04 23:51

using the following I add the file name to the front of each line and send the output to a single file.

ls | while read file; do sed -e \"s/^/$file/g\" $fil         


        
5条回答
  •  梦谈多话
    2021-01-05 00:33

    untested, try using xargs

    find . -type f | xargs -I FILE sed "s/^/FILE/g" FILE > out
    

提交回复
热议问题