My script so far can handle the ls
command and returns the files in the directory. Now i am trying to make it handle commands like ls -l /tmp
. Any help?
My script so far:
#!/bin/bash
#set -x
clear
read -p "type a command: " file
read -r -a prog <<<"$file"
IFS=: read -r -a paths <<<"$PATH"
for val in "${prog[@]}" ; do
for path in "${paths[@]}"; do
[[ -x $path/$val ]] && "$path/$val" "$@"
done
done
$@
.Is there any way to take the rest part (-l /tmp
) of the` ls -l /tmp`