'Unix Tip'에 해당되는 글 2건

  1. 2010.11.25 [UnixTip] 파일시스템 inode full
  2. 2009.02.09 [UnixTip] 쉘에서의 산술 비교
파일 시스템 inode full

파일시스템의 inode 사용량이 100%로 full이 된 경우 파일이 많은 디렉토리를
찾기란 쉽지 않다. 만일 파일 사이즈가 작은 경우 du에 의존하기도 힘들다.

이 경우 다음의 명령을 사용하면 현재 파일시스템에서 디렉토리와 그에 속한
파일의 수를 출력할 수 있다.

find . -xdev -type d -exec /bin/echo -n "{} : " \; -exec sh -c "ls {} | wc -l" \;

옵션설명)
-xdev : 다른 파일시스템은 검색하지 않기
-type d : 파일 타입이 d인 경우(디렉토리), f : 일반파일, l : 링크
-exec : 명령 수행

※ 원문 내용에 첨삭함.

------------------------------------------ 원문 ----------------------------------------------

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

                             UNIX GURU UNIVERSE
                                UNIX HOT TIP

                       Unix Tip 3577 - November 25, 2010

                   http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


FULL OF FILESYSTEM INODES

We recently had a problem where a file system had 100% inode usage.
Unfortunately there isn't an easy way to search for directories with
a lot of files in them (1 file = 1 inode). And if the files are small,
you can't rely on du to help you out.

Here is a find command that will print all the directories in the
current filesystem, with the number of files (inodes) in that directory.

find . -xdev -type d -exec /bin/echo -n {} \; -exec sh -c "ls {} | wc -l" \;

반응형
Posted by She쥐포s

Unix 쉘에서의 산술 비교

Unix 쉘에서의 산술 비교는 정수값에 한정되어 있다. 다음은 기본적인
쉘 명령을 사용하여 부동 소수값을 비교하는 팁이다.

--------- CUT HERE-----------------
#! /bin/sh
# test shell script
n1="01.401"
n2="01.350"

function compareFloatSmall
{
sort -n <<: | head -1
$n1
$n2
:
}

function compareFloatGreat
{
sort -r -n <<: | head -1
$n1
$n2
:
}

small=$(compareFloatSmall $n1 $n2)
echo "Comparing $n1 to $n2: smaller $less"
great=$(compareFloatGreat $n1 $n2)
echo "Comparing $n1 to $n2: greater $great"
--------- CUT HERE-----------------

다른 방법으로 'awk' 프로그램을 사용할 수 있다.
--------- CUT AGAIN HERE-----------
#! /bin/sh
# A couple of examples in awk.
n1="03.550"
n2="02.550"

echo "$n1 $n2" | awk '{
       if ( $1 >= $2 ) print $1
       if ( $1 <= $2 ) print $2
       if ( $1 >  $2 ) print $1
       if ( $1 <  $2 ) print $2
       if ( $1 == $2 ) print $1, $2
}'
--------- CUT AGAIN HERE-----------

<><><><><><><><><><>원 문<><><><><><><><><><><>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

                             UNIX GURU UNIVERSE
                                UNIX HOT TIP

                       Unix Tip 2926 - February  9, 2009

                   http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


ARITHMETIC COMPARISON

In UNIX shell arithmetic comparison
is limited to integer values.  Here
is a tip to compare floating values
using basic shell commands.

--------- CUT HERE-----------------

#! /bin/sh
# test shell script
n1="01.401"
n2="01.350"

function compareFloatSmall
{
sort -n <<: | head -1
$n1
$n2
:
}

function compareFloatGreat
{
sort -r -n <<: | head -1
$n1
$n2
:
}

small=$(compareFloatSmall $n1 $n2)
echo "Comparing $n1 to $n2: smaller $less"
great=$(compareFloatGreat $n1 $n2)
echo "Comparing $n1 to $n2: greater $great"

--------- CUT HERE-----------------

Alternatively you can use a small 'awk' program.

--------- CUT AGAIN HERE-----------
#! /bin/sh
# A couple of examples in awk.
n1="03.550"
n2="02.550"

echo "$n1 $n2" | awk '{
       if ( $1 >= $2 ) print $1
       if ( $1 <= $2 ) print $2
       if ( $1 >  $2 ) print $1
       if ( $1 <  $2 ) print $2
       if ( $1 == $2 ) print $1, $2
}'
--------- CUT AGAIN HERE-----------

반응형
Posted by She쥐포s
이전버튼 1 이전버튼

블로그 이미지
She쥐포s
Yesterday
Today
Total

달력

 « |  » 2024.4
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

최근에 올라온 글

최근에 달린 댓글

글 보관함