Printing inode info from grep

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I'm currently learning Linux, and some of the practice I've has me absolutely stumped.
I'm trying to look for a file in the current directory with particular text, and output its inode number.
I can confidently do all these things individually but it keeps falling apart when I try to put them together;



 find. -maxdepth 1 -type f | grep -r "#include" -ls -i 


but for some reason it just outputs the file names?



Any ideas?







share|improve this question












migrated from stackoverflow.com Oct 29 '17 at 12:56


This question came from our site for professional and enthusiast programmers.














  • Would find . -maxdepth 1 -type f | grep -r "#include" | ls -i bring you any closer to what you are looking for?
    – arkascha
    Oct 28 '17 at 8:28














up vote
0
down vote

favorite












I'm currently learning Linux, and some of the practice I've has me absolutely stumped.
I'm trying to look for a file in the current directory with particular text, and output its inode number.
I can confidently do all these things individually but it keeps falling apart when I try to put them together;



 find. -maxdepth 1 -type f | grep -r "#include" -ls -i 


but for some reason it just outputs the file names?



Any ideas?







share|improve this question












migrated from stackoverflow.com Oct 29 '17 at 12:56


This question came from our site for professional and enthusiast programmers.














  • Would find . -maxdepth 1 -type f | grep -r "#include" | ls -i bring you any closer to what you are looking for?
    – arkascha
    Oct 28 '17 at 8:28












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm currently learning Linux, and some of the practice I've has me absolutely stumped.
I'm trying to look for a file in the current directory with particular text, and output its inode number.
I can confidently do all these things individually but it keeps falling apart when I try to put them together;



 find. -maxdepth 1 -type f | grep -r "#include" -ls -i 


but for some reason it just outputs the file names?



Any ideas?







share|improve this question












I'm currently learning Linux, and some of the practice I've has me absolutely stumped.
I'm trying to look for a file in the current directory with particular text, and output its inode number.
I can confidently do all these things individually but it keeps falling apart when I try to put them together;



 find. -maxdepth 1 -type f | grep -r "#include" -ls -i 


but for some reason it just outputs the file names?



Any ideas?









share|improve this question











share|improve this question




share|improve this question










asked Oct 28 '17 at 8:16







StarLord











migrated from stackoverflow.com Oct 29 '17 at 12:56


This question came from our site for professional and enthusiast programmers.






migrated from stackoverflow.com Oct 29 '17 at 12:56


This question came from our site for professional and enthusiast programmers.













  • Would find . -maxdepth 1 -type f | grep -r "#include" | ls -i bring you any closer to what you are looking for?
    – arkascha
    Oct 28 '17 at 8:28
















  • Would find . -maxdepth 1 -type f | grep -r "#include" | ls -i bring you any closer to what you are looking for?
    – arkascha
    Oct 28 '17 at 8:28















Would find . -maxdepth 1 -type f | grep -r "#include" | ls -i bring you any closer to what you are looking for?
– arkascha
Oct 28 '17 at 8:28




Would find . -maxdepth 1 -type f | grep -r "#include" | ls -i bring you any closer to what you are looking for?
– arkascha
Oct 28 '17 at 8:28










2 Answers
2






active

oldest

votes

















up vote
2
down vote













find . -type f -exec grep '#include' ; -printf '%p %in'


or grep -q to hide grep output



find . -type f -exec grep -q '#include' ; -printf '%p %in'





share|improve this answer



























    up vote
    1
    down vote













    If you are using grep in recursive mode -r - you don't actually need find command:



    grep + xargs approach:



    grep -rl '#include' | xargs -I ls -i ''


    An approximate output (<inode> <filename>):



    1837827 test/1.pdb
    1712970 2_clean.pdb
    1837846 test2/2.pdb
    1712965 1_clean.pdb





    share|improve this answer




















    • I assume that grep requires a filename or data via stdin.
      – Cyrus
      Oct 28 '17 at 9:45










    • @Cyrus, explain your phrase
      – RomanPerekhrest
      Oct 28 '17 at 9:46










    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f401219%2fprinting-inode-info-from-grep%23new-answer', 'question_page');

    );

    Post as a guest





























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    find . -type f -exec grep '#include' ; -printf '%p %in'


    or grep -q to hide grep output



    find . -type f -exec grep -q '#include' ; -printf '%p %in'





    share|improve this answer
























      up vote
      2
      down vote













      find . -type f -exec grep '#include' ; -printf '%p %in'


      or grep -q to hide grep output



      find . -type f -exec grep -q '#include' ; -printf '%p %in'





      share|improve this answer






















        up vote
        2
        down vote










        up vote
        2
        down vote









        find . -type f -exec grep '#include' ; -printf '%p %in'


        or grep -q to hide grep output



        find . -type f -exec grep -q '#include' ; -printf '%p %in'





        share|improve this answer












        find . -type f -exec grep '#include' ; -printf '%p %in'


        or grep -q to hide grep output



        find . -type f -exec grep -q '#include' ; -printf '%p %in'






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 28 '17 at 9:17









        Nahuel Fouilleul

        1,06667




        1,06667






















            up vote
            1
            down vote













            If you are using grep in recursive mode -r - you don't actually need find command:



            grep + xargs approach:



            grep -rl '#include' | xargs -I ls -i ''


            An approximate output (<inode> <filename>):



            1837827 test/1.pdb
            1712970 2_clean.pdb
            1837846 test2/2.pdb
            1712965 1_clean.pdb





            share|improve this answer




















            • I assume that grep requires a filename or data via stdin.
              – Cyrus
              Oct 28 '17 at 9:45










            • @Cyrus, explain your phrase
              – RomanPerekhrest
              Oct 28 '17 at 9:46














            up vote
            1
            down vote













            If you are using grep in recursive mode -r - you don't actually need find command:



            grep + xargs approach:



            grep -rl '#include' | xargs -I ls -i ''


            An approximate output (<inode> <filename>):



            1837827 test/1.pdb
            1712970 2_clean.pdb
            1837846 test2/2.pdb
            1712965 1_clean.pdb





            share|improve this answer




















            • I assume that grep requires a filename or data via stdin.
              – Cyrus
              Oct 28 '17 at 9:45










            • @Cyrus, explain your phrase
              – RomanPerekhrest
              Oct 28 '17 at 9:46












            up vote
            1
            down vote










            up vote
            1
            down vote









            If you are using grep in recursive mode -r - you don't actually need find command:



            grep + xargs approach:



            grep -rl '#include' | xargs -I ls -i ''


            An approximate output (<inode> <filename>):



            1837827 test/1.pdb
            1712970 2_clean.pdb
            1837846 test2/2.pdb
            1712965 1_clean.pdb





            share|improve this answer












            If you are using grep in recursive mode -r - you don't actually need find command:



            grep + xargs approach:



            grep -rl '#include' | xargs -I ls -i ''


            An approximate output (<inode> <filename>):



            1837827 test/1.pdb
            1712970 2_clean.pdb
            1837846 test2/2.pdb
            1712965 1_clean.pdb






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Oct 28 '17 at 9:19









            RomanPerekhrest

            22.5k12145




            22.5k12145











            • I assume that grep requires a filename or data via stdin.
              – Cyrus
              Oct 28 '17 at 9:45










            • @Cyrus, explain your phrase
              – RomanPerekhrest
              Oct 28 '17 at 9:46
















            • I assume that grep requires a filename or data via stdin.
              – Cyrus
              Oct 28 '17 at 9:45










            • @Cyrus, explain your phrase
              – RomanPerekhrest
              Oct 28 '17 at 9:46















            I assume that grep requires a filename or data via stdin.
            – Cyrus
            Oct 28 '17 at 9:45




            I assume that grep requires a filename or data via stdin.
            – Cyrus
            Oct 28 '17 at 9:45












            @Cyrus, explain your phrase
            – RomanPerekhrest
            Oct 28 '17 at 9:46




            @Cyrus, explain your phrase
            – RomanPerekhrest
            Oct 28 '17 at 9:46

















             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f401219%2fprinting-inode-info-from-grep%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay