Trying to store to a variable, a specific section (type of file) from the response of the file command.
The first echo line, the one that is piped into cut, already outputs the correct information on screen. However, I need to later use that in conditioning, so it's required to store this in the 'type' variable. I have tried various ways but they didn't work, for example type=$(($cmd) | cut -d " " -f 2), as well as using redirects and pipes.
#! /usr/bin/env bash
cmd="archive"
type=""
cmd="file $cmd"
echo $($cmd) | cut -d " " -f 2
type=???
echo "File Type is: $type"