Implement a formatted shell script output
AmazonSoftware Engineer · Technical ScreenLast updated
This interview question evaluates algorithm design, data structures, correctness, complexity, edge cases, and implementation details in a realistic interview setting. A strong answer for Implement a formatted shell script output states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.
Write a shell script named script.sh that is invoked as: ./script.sh <username> <path_of_file>. It must print a single line formatted exactly as: <timestamp> <license> user@hostname. Use the supplied username and the current machine’s hostname, and parse the license value from the file at <path_of_file>. Include argument validation (missing args), file existence/permission checks, and clearly define the timestamp format you choose.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.