In this Leetcode Tenth Line problem solution we have Given a text file file.txt, print just the 10th line of the file.

Leetcode Tenth Line problem solution


First Problem solution.

LINE=1
while read -r CURRENT_LINE
do
if [ "$LINE" -eq "10" ]
then
echo $CURRENT_LINE
fi
((LINE++))
done < "./file.txt"



Second Problem solution.

cat file.txt | sed -n '10p'


Third Problem solution.

sed '10q;d' file.txt