SIMULATION -
1. Find all sizes of 10k file or directory under the /etc directory, and copy to /tmp/findfiles directory.
2. Find all the files or directories with Lucy as the owner, and copy to /tmp/findfiles directory.
SIMULATION -
1. Find all sizes of 10k file or directory under the /etc directory, and copy to /tmp/findfiles directory.
2. Find all the files or directories with Lucy as the owner, and copy to /tmp/findfiles directory.
To accomplish the tasks specified in the question, you need to use the 'find' command to locate the relevant files and then copy them to the '/tmp/findfiles' directory. Here are the correct commands for each task: 1. To find all files or directories of 10k size under the '/etc' directory and copy them to '/tmp/findfiles' directory, use: 'find /etc -size 10k -exec cp -a {} /tmp/findfiles \;'. The '-a' option is used with 'cp' to preserve file attributes, including ownership and permissions. 2. To find all files or directories owned by the user 'lucy' and copy them to '/tmp/findfiles' directory, use: 'find / -user lucy -exec cp -a {} /tmp/findfiles \;'. Again, the '-a' option is used to ensure that the file attributes are preserved during the copy operation.
#mkdir /tmp/findfiles # find /etc -size 10k -exec cp -r {} /tmp/findfiles \; # find / -user lucy -exec cp -r {} /tmp/findfiles \;
I would use cp -a to preserve the ownership.
mkdir /tmp/findfiles cp $(find /etc -size 10k) /tmp/findfiles/ cp $(find / -user lucy) /tmp/findfiles/
How would you check to see what is in the directory to verify your search?
Why not just use the following: find /etc -size 10k > /tmp/findfiles find / -user lucy >> /tmp/findfiles
/tmp/findfiles is a directory. You can only append to files
This is just redirecting your command output to a file, but not copying the files to a directory