In: Computer Science
Linux Fundamentals part 4 final Below are questions related to the command line use of Linux. You can use the videos, man pages, and notes to answer these questions. Remember that Linux is CASE SENSITIVE. Rm and rm are NOT the same command. I will count off totally for a question if you do not take this into account. For each command give me the ENTIRE COMMAND SEQUENCE. If I ask you 'What command would I use to move the file one.txt to the parent directory and rename it to two.txt?", the answer is NOT 'mv'. That is only part of the command. I want the entire command sequence.
16. Find all files under ~ whose content contain the keyword taco OR Taco OR taCo OR tacO. NOT all variations in case for 'taco', but just the variations listed meaning a keyword of tAco, tACO, tACo, etc, will not produce a result.
17. Find all files under the current directory which ends in
'.txt' (just the .txt not the single quotes) and use -exec to
create a listing of each files inode number. Since we're using
-exec, this means we will call another command to produce the inode
based on the results found. What command do we use to make
listings? Now you just need to find how to make it produce an inode
result. To the man page!
18. What command would I run to update the database of file
names used by the locate command?
19. Find all files under the /var directory with a size less
than 1 kilobyte. Use -exec and an appropriate command to copy those
files to ~/Documents/FallFun/sep.
20. Find all files under the ~ directory that are named
'Picard' ignoring case.
Ans 16 :- This command will find all the files with the given keywords. (r is for recursive search, l is for showing only file name, w is used to search for an exact word.
grep -rlw 'taco\|Taco\|taCo\|tacO'
Ans 17: find command wil find all the txt files in the current directory (.) and will display the inode number for each file via exec command.
find . -name '*.txt' -exec ls -i \;
Ans 18: This command will update the database used to store files used by locate command. updatedb is usually run daily by cron to update the database.
sudo updatedb
Ans 19: This command will find all the files in /var directory less than 1kb size and will copy these files to ~/Documents/FallFun/sep directory via -exec command.
find /var -type f -size 1k -exec cp {} ~/Documents/FallFun/sep/ \;
Ans 20: This command will find recursively all the files with the name Picard. -iname is for ignoring the case while querying the name.
find ~ -iname 'Picard*'
Hope it helps. Thanks!