2013-04-19 3 views

답변

1

루프에 대한 추가 :

#!/bin/bash 
echo 'Enter file names (wild cards OK)' 
read input_source 
if test -f "$input_source" 
then 
sort $var | uniq -c | head -10 
fi 
+0

감사합니다! 그리고 내가 $ sort_source | 유니크 -c | 사용자가 파일의 끝을 알릴 때까지 입력 파일에 대해 -10을 계속 반복하십시오. Ctrl-d를 파일 이름으로 입력하면됩니다. 어떤 아이디어? – Zerg12

1

는 while 루프를 사용하여 또는 다른 말로 다음 스크립트로 여러 파일을 처리하는

#!/bin/bash 
echo 'Enter file names (wild cards OK)' 
read files 
for input_source in $files ; do 
    if test -f "$input_source" ; then 
     sort $var | uniq -c | head -10 # You probably should include $input_source somewhere 
    fi 
done 
1

그냥 고양이 모든 파일을 그 입력 패턴과 일치 : -

#!/bin/bash 
echo 'Enter file names (wild cards OK)' 
read input_source 
cat $input_source | sort | uniq -c | head -10 
관련 문제