Rikardo Rikardo - 3 months ago 11
Linux Question

CentOS - displaying 1 line of file only

echo "Enter line number to display"
read number
sed -n $number /etc/passwd

I need to display only one line of text given by the user, in possible easy way. Above line is giving me error:
sed -e expression char3,extra characters after command.

What am I doing wrong?


the correct command is:

sed -n ${number}p /etc/passwd

(p is command to print)