No products in the cart.
- This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
- AuthorPosts
-
April 17, 2011 at 10:02 am #9656
abctest483MemberI’m looking for a command that use grep to search in /usr/bin for all the files who have 2 links and sort them in ascending.
The second command I’m looking for must use the first one and display just the files that contain the “x”
Thanks you
April 17, 2011 at 10:56 am #9657
abctest483MemberThis would do
find /usr/bin -links 2 -print0 | xargs -0 ls -adltrmodify the ls to do the sorting you require
find /usr/bin -links 2 -print0 | xargs -0 grep -l "x"Files containing the “x” 🙂
If you meant: ‘contain the x’ as ‘are executable (x appears in ls -l output), use
find /usr/bin -links 2 -executable -print0 | ls -adltrTo see only dirs:
find /usr/bin -links 2 -type d -executable -print0 | ls -adltrTo see only files:
find /usr/bin -links 2 -type f -executable -print0 | ls -adltrNote: directories get 2 links by default (
.is a link) so you might want to look for-links 3with directoriesJuly 22, 2011 at 2:05 am #9658
abctest483MemberYou can do this direct from grep, eg:
grep -r --include=*.py "HOSTS" .will search recursively (‘-r’) under the current directory (‘.’) in all python files (‘*.py’) for the string “HOSTS”.
- AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.