Printing inode info from grep
Clash 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?
linux bash
migrated from stackoverflow.com Oct 29 '17 at 12:56
This question came from our site for professional and enthusiast programmers.
add a comment |Â
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?
linux bash
migrated from stackoverflow.com Oct 29 '17 at 12:56
This question came from our site for professional and enthusiast programmers.
Wouldfind . -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
add a comment |Â
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?
linux bash
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?
linux bash
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.
Wouldfind . -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
add a comment |Â
Wouldfind . -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
add a comment |Â
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'
add a comment |Â
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
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
add a comment |Â
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'
add a comment |Â
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'
add a comment |Â
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'
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'
answered Oct 28 '17 at 9:17
Nahuel Fouilleul
1,06667
1,06667
add a comment |Â
add a comment |Â
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
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
add a comment |Â
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
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
add a comment |Â
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
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
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
add a comment |Â
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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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