Get number of lines of a text file and assign this value to a variable
num_lines=($(wc -l <file_name>))
We have 5 lines.
num_lines=($(wc -l Fruits.txt)) echo "The number of lines in Fruits.txt is $num_lines"
It will print “The number of lines in Fruits.txt is 5”
Write log of a command in terminal to file
<command> > <log_file>
echo "Have a nice working day!" > happy.txt
Have a nice working day!