- 파일 테스팅 : 파일, 디렉터리, 텍스트 등의 속성을 테스트하기 위해 여러가지 옵션을 가지고 확인할 수 있다.

 

- [ ] 안의 조건식에 사용할 수 있는 테스트 연산자의 종류

  

- 예시

vi test123.txt                    // 빈 파일 생성

vi testing.sh

 

#!/bin/sh

 

if [ -f /shellTest/*.txt ]               // 경로 /shellTest 에 파일이 존재하는지

then

   echo "file exists"

else

   echo "file not found"

fi

'Linux Shell script' 카테고리의 다른 글

while, for문  (0) 2020.11.26

While문

1. while.sh 파일 생성

vi while.sh

[ $number -lt 10 ] [ $number < 10 ]   

   [ $number -le 10 ] → [ $number <= 10 ]   

   [ $number -eq 10 ] → [ $number = 10 ]

 

#!/bin/sh

number=0
while [ $number -lt 10 ]           
do
echo "$number"
number=`expr $number + 1`
done
echo "script complete."

 

2. 실행 결과

./shile.sh

 

0

1

2

3

4

5

6

7

8

9

script complete.

 

for문

for 단일변수 in 리스트

do

~

done

 

1. for.sh 생성

vi for.sh

 

#!/bin/sh

for fruit in apple oranges pears bananas
do
echo $fruit
done
echo "script complete."

 

2. 실행 결과

./for.sh

 

apple

oranges

pears

bananas

script complete.

 

3. 리스트 분리하여 파일 저장

vi tt1.txt

 

apple oranges pears bananas 

 

4. tt1.txt를 리스트 부분에 넣기

#!/bin/sh 

for fruit in $(cat tt1.txt)
do 
echo $fruit 
done 
echo "script complete." 

'Linux Shell script' 카테고리의 다른 글

파일 테스팅  (0) 2020.11.26

이클립스에서 Import 할 때 위 사진와 같이 오류가 발생하는 경우가 있습니다.

(오류 메세지 : Multiple annotations found at this line: - String cannot be resolved to a type)

이러한 오류는 이클립스가 JDK를 인식하지 못하는 상황입니다.

아래와 같이 확인을 해야합니다.

 

1. 프로젝트 마우스 오른쪽 클릭 → Build Path → Configure Build Path... 클릭

 

 

위 사진과 같이 JRE Library에 빨간색으로 X 표시가 되어있는 것을 볼 수 있습니다.

JRE를 제거하고 다시 설정해보겠습니다.

2. JRE System Library 선택 → Remove 클릭

 

 

3. Add Library... 클릭 → JRE System Library 선택 → Next 클릭

 

 

4. Workspace default JRE 선택 → Finish 클릭

 

 

위 사진과 같이 오류 해결된 것을 확인할 수 있습니다!

'JSP' 카테고리의 다른 글

tags, tld 폴더의 경로는 이동할 수 있을까?  (0) 2021.12.21

+ Recent posts