I use the following command to get the output (number tagged in the latest file):
ls -lrt | tail -n1 | awk -F'.' '{print $4}' | grep -o '[0-9]\+'
but when I use the same command in a shell script and get the result in a variable c
, I don't get the proper result.
My script:
#! /bin/sh
c=ls -lrt | tail -n1 | awk -F'.' '{print $4}' | grep -o '[0-9]\+'
echo $c
The error that shows when I execute is:
-lrt: command not found