I have a file which looks like this (file1.txt)
258.2222
I have to write this file1.txt value to another file. if there in no value in file1.txt then
it should print as "Passed".
this is what I tried
for final in $(cat file1.txt);do
if [ "$final" ];then
echo $final > file2.txt
else
echo "Passed" > file2.txt
fi
done
this only works with 1 scenario. if there is no value in file1.txt then it is not writing as "Passed"
expected output:
if there is a value in file1.txt:
258.2222
if there is no value (empty) in file1.txt:
Passed
Can someone help me to figure out this? Thanks in advance!
Note: I am not allowed to use general purpose scripting language (JavaScript, Python etc).