[shell script] for문에서 파일의 문자열 반복

HYEOB KIM·2022년 4월 18일
0

Shell

목록 보기
17/71

먼저 states라는 파일을 만들고 아래의 내용을 입력합니다.

$ cat states
A B C D E F

그리고 states 파일의 내용을 띄어쓰기를 기준으로 반복하며 출력해보겠습니다.

$ cat test1
#!/bin/bash
for test in $(cat states)
do
        echo "word: $test"
done 

$ ./test1
word: A
word: B
word: C
word: D
word: E
word: F
profile
Devops Engineer

0개의 댓글