leetcode icon indicating copy to clipboard operation
leetcode copied to clipboard

TenthLine - bash

Open hinell opened this issue 1 year ago • 0 comments

Well I think the example given in the TenthLine.sh is a pure cheating. Here a few good examples for faster bash solution:

declare i=1;
while read line;
do ((++i)); [[ i -eq 11 ]] && echo $line;
done < file.txt

or

IFS=$'\n' readarray arr < file.txt; echo ${arr[9]}

hinell avatar Aug 30 '22 12:08 hinell