I have a bash script which looks like
#!bin/bash
array to store my commands
COMMANDS=(route
ls -l
)
here I want to iterate through the array, run all the commands and take
screenshot of each after their execution to be put into my lab assignment file.
for (( i=0; i<${#COMMANDS[@]}; i=i+1 )); do
clear
"${COMMANDS[$i]}"
gnome-screenshot -w -f "$i".png
done
But the output looks like
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default _gateway 0.0.0.0 UG 600 0 0 wlx00e02d4a265d
link-local 0.0.0.0 255.255.0.0 U 1000 0 0 docker0
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
192.168.43.0 0.0.0.0 255.255.255.0 U 600 0 0 wlx00e02d4a265d
5.png Downloads my_rust_projects sys-info
6.png FINAL450.pdf Pictures Templates
-l: command not found
How can I achieve the desired result for ls -l
which is the detailed entry for each file?
-l
inls -l
is the argument. I think it the cause of the error. – Rudresh Dixit Dec 01 '20 at 15:53