我需要打印行号以及用户提示的内容,怎么办?我尝试了以下代码,但它不起作用



即使行号多于当前内容,它也必须显示空行的行号,然后在指定的行号中打印用户输入的内容。

#!/bin/bash
file2='file2.txt'
echo -en "Enter the line number:"
read line_number
echo -en "Enter the name of the city:"
read city_name 
total= 0
if [ "$line_number" > "$total" ]
then
awk -v  city_name="$city_name" -v line_no="$line_no" -F, {print 
city_name} 1' "file2"
fi

-lt/-gt代替"& lt;/祝辞">

>>> x=7
>>> y=99
>>> if [ $x < $y ] ; then echo "x < y"; else echo "x >= y" ; fi
x >= y
>>> if [[ $x -lt $y ]] ; then echo "x < y"; else echo "x >= y" ; fi
x < y

或者使用双[[]]

>>> if [[ $x < $y ]] ; then echo "x < y"; else echo "x >= y" ; fi
x < y