Determine whether extensionless downloaded_item is text, an image, or an executable by inspecting its contents.
Which command is appropriate?
file uses content signatures and related information rather than relying only on the filename extension.
Detailed explanation
file downloaded_itemCorrect. file downloaded_item reports a type based on content and signatures.
Correct. file downloaded_item reports a type based on content and signatures.
ls downloaded_itemIncorrect. ls lists a file and its metadata but does not identify content type in this way.
Incorrect. ls lists a file and its metadata but does not identify content type in this way.
touch downloaded_itemIncorrect. touch creates or updates a timestamp.
Incorrect. touch creates or updates a timestamp.
type downloaded_itemIncorrect. type explains shell command resolution.
Incorrect. type explains shell command resolution.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp); printf 'hello\n' >"$tmp"; file "$tmp"; rm -f "$tmp"Expected result
末尾にASCII textなど、テキストと分かる種別が表示されるKey points
- file inspects content
- ls lists names and attributes
- type resolves commands
Notes
- Environment: Linux / fileコマンド / 一時ファイル
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.