Hi I need a help for the question "File Descriptors and Redirections
"of “Linux Foundamentals”.
I have done various tests on both the virtual machine and the host with the commands:
$ find -type f -name * .log | wc but the answer is never correct.
can anyone help me?
Check your command is starting from the right place and look through the output to see if you’ve pulled in something incorrect. For example, in what you’ve pasted here there is a small typo that will cause unintended results.
Type your comment> @TazWake said:
Check your command is starting from the right place and look through the output to see if you’ve pulled in something incorrect. For example, in what you’ve pasted here there is a small typo that will cause unintended results.
I’m sorry but I really can’t find the error.
With the command:
find -type f -name * .log | wc
I shouldn’t find all the .log files on the system?
Probably not but it depends where you are on the file system when you run it.
Have a look at the output and see if it is what you expect.
I would suspect two things are missing:
- the path to start in
- a space between * and .
Also - generally I find it is better to use -iname and " … " around the term for this but ymmv.
I think you should check the hint about the “the path to start in” as depending in which folder you are it will return different results so you’d better specify where find should start searching.
There is a couple typos, take a look at what comes next after find and after wc. I was doing the same thing, but your code and TazWake first comment helped me.
I have tried every combination that i could imagine and still i cant find the answer !!!
find /var/log -type f -name *.log | wc -l , ( as i understood we are searching the provided VM ) can someone give me the exact command because i am stack and i cant move on
@PROILAS135 said:
I have tried every combination that i could imagine and still i cant find the answer !!!
find /var/log -type f -name *.log | wc -l , ( as i understood we are searching the provided VM ) can someone give me the exact command because i am stack and i cant move on
Anyway found it i was searching on the provided machine and not on the target system , nobody mention it anyway thanks i guess
!!!
I have SSH’d to the target then entered this entry but still the number is not accepted… can anyone guide for another entry or tell me what’s wrong?
htb-student@nixfund:~$ find /var/log -type f -iname *.log | wc -l
find: ‘/var/log/unattended-upgrades’: Permission denied
find: ‘/var/log/mysql’: Permission denied
find: ‘/var/log/samba’: Permission denied
find: ‘/var/log/apache2’: Permission denied
24
still not accepting the answer!!!
Type your comment> @4Bros said:
I have SSH’d to the target then entered this entry but still the number is not accepted… can anyone guide for another entry or tell me what’s wrong?
htb-student@nixfund:~$ find /var/log -type f -iname *.log | wc -l
find: ‘/var/log/unattended-upgrades’: Permission denied
find: ‘/var/log/mysql’: Permission denied
find: ‘/var/log/samba’: Permission denied
find: ‘/var/log/apache2’: Permission denied
24still not accepting the answer!!!
I don’t know what the correct answer is, so please take this with that in mind.
- Does the question ask how many files in
/var/log
have .log as the extension? - Are you sure the data being returned from the find command doesn’t include any spurious lines? It’s worth running it without
wc -l
first to see what the results look like before you assume they are all valid lines. - You might find it’s better to use “…” around the search string.
Thanks, got it
I have to CD … all the way until i reach the main directory (htb-student@nixfund:/$) then i put the entry after that the number will show but at the beginning I have to SSH to the target.
htb-student@nixfund:/$ find -name *.log 2>/dev/null | wc -l
@4Bros said:
Thanks, got it
I have to CD … all the way until i reach the main directory (htb-student@nixfund:/$) then i put the entry after that the number will show but at the beginning I have to SSH to the target.
htb-student@nixfund:/$ find -name *.log 2>/dev/null | wc -l
You can get a similar effect with find / -iname "*.log" 2>/dev/null | wc -l
I dunno whats going on I tried every way of finding .log files ext but still the answer is wrong.
Im running this cmd, it gives me all the extensions in the system:
find . -type f | sed -n ‘s/…*.//p’ | sort | uniq -c
find / -type f -name .log 2>/dev/null | wc -l
you will get the correct answer : 3
don’t know if you still need help but if you put the *.log between ’ ’ (single quotes) it works
I ended up using iname instead of name and it worked
Find / -type f -name *.log 2>/dev/null | wc
^this worked for me. All previous post commands would not work. The output was listed as:
32 32 1044
Which I don’t understand
Also, I saw a previous post talking about *(space).log, though my input worked without a space
01010011 01110100 01101001 01101100 01101100 00100000 01101110 01100101 01100101 01100100 00100000 01101000 01100101 01101100 01110000 00100000 01110111 01101001 01110100 01101000 00100000 01110100 01101000 01101111 01110011 01100101 00100000 01101100 01101111 01100111 01110011 00111111 00100000 01001100 01101111 01101100 00100000