B
B
barri22020-04-28 19:06:56
bash
barri2, 2020-04-28 19:06:56

Need help with bash. What is wrong in this code?

k=$(cat $1 | wc -l)
if (($k<10) && ($k>1)); then
 echo $1
fi

What is wrong in this code? It doesn't work, which is very strange for me.
It should display text file names that have more than one line of text and less than 10.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vadim, 2020-04-28
@barri2

k=$(cat $1 | wc -l)

if [ $k -lt 10 ] && [ $k -gt 1 ]
then
 echo $1
fi

A
Alexey, 2020-05-01
@AlexeyKolodchenko

as option
#! /bin/bash
k=$(cat $1 | wc -l)
if (( $k > 1 && $k < 10 )); then
echo $1
fi

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question