How to resolve the algorithm Take notes on the command line step by step in the UNIX Shell programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Take notes on the command line step by step in the UNIX Shell programming language
Table of Contents
Problem Statement
Invoking NOTES without commandline arguments displays the current contents of the local NOTES.TXT if it exists. If NOTES has arguments, the current date and time are appended to the local NOTES.TXT followed by a newline. Then all the arguments, joined with spaces, prepended with a tab, and appended with a trailing newline, are written to NOTES.TXT. If NOTES.TXT doesn't already exist in the current directory then a new NOTES.TXT file should be created.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Take notes on the command line step by step in the UNIX Shell programming language
Source code in the unix programming language
#
NOTES=$HOME/notes.txt
if [[ $# -eq 0 ]] ; then
[[ -r $NOTES ]] && more $NOTES
else
date >> $NOTES
echo " $*" >> $NOTES
fi
N=~/notes.txt;[[ $# -gt 0 ]] && { date ; echo " $*"; exit 0; } >> $N || [[ -r $N ]] && cat $N
NOTES=$HOME/notes.txt
if test "x$*" = "x"
then
if test -r $NOTES
then
more $NOTES
fi
else
date >> $NOTES
echo " $*" >> $NOTES
fi
You may also check:How to resolve the algorithm Check output device is a terminal step by step in the Lua programming language
You may also check:How to resolve the algorithm Largest number divisible by its digits step by step in the Perl programming language
You may also check:How to resolve the algorithm Sudan function step by step in the Pascal programming language
You may also check:How to resolve the algorithm Long year step by step in the Kotlin programming language
You may also check:How to resolve the algorithm File size distribution step by step in the Go programming language