Bruno Domingues:
For challenge 4 is can someone confirm what I’m doing wrong?
find preserved/ -type f -name "\.*" | wc -l (1200)
ls -la preserved/ | wc -l (1200)
find preserved/ -type f -name "\.*" -exec cp -v {} /opt/appdata/hidden/ \;
wrong
find preserved/ -type f -not -iname "\.*" | wc -l (8006)
ls -l preserved/ | wc -l (8007)
find preserved/ -type f -not -iname "\.*" -exec cp -v {} /opt/appdata/files/ \;
wrong
grep -Er "t$" /opt/appdata/ | wc -l (300)
not sure how to pipe this to rm -f properly
Aaron Lockhart:
@Bruno Domingues: In general, with find
you can use the -exec
option to pass the results to another command.
For other commands, you can use a format like rm -f $(command -arguments)
, but you have to be careful with that type of formulation, as the shell will expand the contents of $(command -arguments)
, so make sure everything is formatted to expect that.
Bruno Domingues:
So for example to delete all files ending with t would something like this work?
rm -f $(grep -Er "t$" /opt/data/)
Vamsee Krishna:
Hi Bruno, If you are trying to delete files after finding them using find command… this might help…
find . -name "FILE-TO-FIND" -exec rm -rf {} \;
Aaron Lockhart:
I will note here that if the question is asking you to find files that contain a line that end with the letter “t”, the grep
command will be applicable, rather than the find
command.
Bruno Domingues:
@Vamsee Krishna trying to delete a string in files not find a specific file to delete. As @Aaron Lockhart mentioned grep will suit better.
Bruno Domingues:
Hey @Aaron Lockhart can you give me a hint with this one? Why does this command not work for this task? I’ve created the /opt/appdata/hidden and files directories already
Find the "hidden" files in "/home/bob/preserved" directory and copy them in "/opt/appdata/hidden/" directory (create the destination directory if doesn't exist).
[root@centos-host bob]# find preserved/ -iname '[.]*' -type f -exec cp -vR {} /opt/appdata/hidden/ \;
Find the "non-hidden" files in "/home/bob/preserved" directory and copy them in "/opt/appdata/files/" directory (create the destination directory if doesn't exist).
[root@centos-host bob]# find preserved/ -type f -not -iname "\.*" -exec cp -v {} /opt/appdata/files/ \;
Aaron Lockhart:
@Bruno Domingues is it not copying your files, or is it just displaying that it is not correct? If it’s not displaying it as correct when it’s checked, it’s because that challenge may not show things as correct until all steps are completed, even if that step is correct.
Bruno Domingues:
I think I figured it out I had to complete the third task for the first and second to be checked as complete. I spent too much time thinking I was doing it wong
Aaron Lockhart:
That one is particularly tricky for that reason. You have to know you’re right and stay confident about it, which isn’t easy.
Bruno Domingues:
Took me 2 days but I finally completed that one! Thanks again Aaron!
Hi @durgakumari813 ,
Can you please paste your commands in the code block?
It would be visible clearly and easy to read.
Please check the attached SS for convenience.
Regards,
KodeKloud Support
Hello everyone,
can you please tell me this question what exactly want .
command what i used is : zgrep -ai processed /opt/appdata.tar.gz > /home/bob/filtered.txt
but i don’t know in second part it’s saying overwrite the content but i don’t see any content inside that /home/bob/filtered.txt
can anyone explain me what exactly this question is saying
you got any solutions for this tasls
Hi @Penchulaiah-Mandadi ,
Solutions are available here.
Feel free to fork and give it a star.
Regards,