[英]I need to print the line number along with the content prompting from user, How to do that?
[英]I need to print the line number along with the content prompting from user, How to do that? I tried this following code but it doesn't work
即使行號多於當前內容,它也必須顯示空行的行號,然后在指定的行號中打印用戶輸入的內容。
#!/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
代替 '</>'
>>> 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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.