Create a shell script that would receive as a parameter (from the command line)
ID: 3805980 • Letter: C
Question
Create a shell script that would receive as a parameter (from the command line) the number of days from epoch (January 1, 1970) and display the date in a human readable way, please check the screen shot.
optech@localhost: N/Documents/cst488/exercises File Edit View Search Terminal Tabs Help x optech@local host /Docu x optech@localhost: /etc op host exercises]$ get date .s h 144 tech@localh 69 for a shadow date of: 14469 the human date is: Wed Aug 12 17:00:00 MST 2009 optech@local host exercises]$Explanation / Answer
Hi,
Here is the shell scrpit for epoch time conversion:
#/bin/bash
echo 'Welcome to epoch converter';
echo 'Your converted epoch time is:';
echo $1 | perl -pe 's/(d+)/localtime($1)/e' ;
The part in bold in script.
Please copy paste the the script in text editor and save as <file_name>.sh
Give 777 permissions by chmod -R 777 <file_name>
The method to use the script:
./<filename.sh> 1190000000
Sample output:
./demo.sh 1190000000
Welcome to epoch converter
Your converted epoch time is:
Mon Sep 17 09:03:20 2007
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.