I have the following code:
ls *.bat | wc -l
What this does is to count the number of files in the home directory that have the 'bat' extension. I want to run an IF statement off the result. I want to place the results (in this case 5) into the variable but can't quite accomplish it. I can pipe or redirect it to a file and read the file but that seems a bit much.
I want to essentially accomplish the following:
countvariable="ls *.bat | wc -l"
if
$countvariable -ge 2
then
do stuff
else
do other stuff
elif
Ideas? Thanks in advance!
ls *.bat | wc -l
What this does is to count the number of files in the home directory that have the 'bat' extension. I want to run an IF statement off the result. I want to place the results (in this case 5) into the variable but can't quite accomplish it. I can pipe or redirect it to a file and read the file but that seems a bit much.
I want to essentially accomplish the following:
countvariable="ls *.bat | wc -l"
if
$countvariable -ge 2
then
do stuff
else
do other stuff
elif
Ideas? Thanks in advance!