Home Tenth Line
Post
Cancel

Tenth Line

Leetcode Problem

Tenth Line

bash shell로 file.txt을 받아서 열번째 줄을 출력하는 문제입니다.

1
2
3
4
5
6
7
8
x=1
while read line; do
  if [[ $x -eq 10 ]]; then
    echo $line
  fi
  x=$x+1
done < file.txt

이전 문제 풀이를 참고했습니다.
if 사용 시의 문법, $를 활용한 변수 선언과 사용에 대해 복습했습니다.





참고 -https://leetcode.com/problems/valid-phone-numbers/submissions/913481816/

This post is licensed under CC BY 4.0 by the author.