Implement a robust shell CLI

Quick Overview

This question evaluates proficiency in POSIX-compliant shell scripting, including positional argument parsing and validation, ISO 8601 UTC timestamp generation, file metadata extraction for license determination, construction of user@hostname, error handling and exit-code semantics, and handling of non-ASCII file paths.

Implement a robust shell CLI

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Implement a POSIX-compliant shell script invoked as ./script.sh <username> <path_of_file> that outputs a single line formatted as "<timestamp> <license> <user@hostname>". Requirements: parse and validate both positional arguments; compute an ISO 8601 UTC timestamp; derive the license string from the file (state and document your assumption, e.g., read a 'License:' header or first token); construct user@hostname using the provided username and the local hostname; handle missing file, permission errors, and non-ASCII paths; return meaningful exit codes; and outline basic tests (happy path, bad args, missing file).

Quick Answer: This question evaluates proficiency in POSIX-compliant shell scripting, including positional argument parsing and validation, ISO 8601 UTC timestamp generation, file metadata extraction for license determination, construction of user@hostname, error handling and exit-code semantics, and handling of non-ASCII file paths.

|Home/Coding & Algorithms/Amazon
Amazon logo
Amazon
Sep 6, 2025, 12:00 AM
mediumSoftware EngineerTechnical ScreenCoding & Algorithms
4
0

Implement a POSIX-compliant shell script invoked as ./script.sh <username> <path_of_file> that outputs a single line formatted as "<timestamp> <license> user@hostname". Requirements: parse and validate both positional arguments; compute an ISO 8601 UTC timestamp; derive the license string from the file (state and document your assumption, e.g., read a 'License:' header or first token); construct user@hostname using the provided username and the local hostname; handle missing file, permission errors, and non-ASCII paths; return meaningful exit codes; and outline basic tests (happy path, bad args, missing file).

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...