Concatenate multiple files but include filename as section headers

前端 未结 20 1706
粉色の甜心
粉色の甜心 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:16

    I like this option

    for x in $(ls ./*.php); do echo $x; cat $x | grep -i 'menuItem'; done
    

    Output looks like this:

    ./debug-things.php
    ./Facebook.Pixel.Code.php
    ./footer.trusted.seller.items.php
    ./GoogleAnalytics.php
    ./JivositeCode.php
    ./Live-Messenger.php
    ./mPopex.php
    ./NOTIFICATIONS-box.php
    ./reviewPopUp_Frame.php
                $('#top-nav-scroller-pos-').addClass('active');
                gotTo**MenuItem**();
    ./Reviews-Frames-PopUps.php
    ./social.media.login.btns.php
    ./social-side-bar.php
    ./staticWalletsAlerst.php
    ./tmp-fix.php
    ./top-nav-scroller.php
    $active**MenuItem** = '0';
            $active**MenuItem** = '1';
            $active**MenuItem** = '2';
            $active**MenuItem** = '3';
    ./Waiting-Overlay.php
    ./Yandex.Metrika.php
    

提交回复
热议问题