'shell'에 해당되는 글 3건

  1. 2009.10.30 unzip으로 특정 파일 추출하기.
  2. 2009.02.09 [UnixTip] 쉘에서의 산술 비교
  3. 2008.09.21 null copy
* 리스트 확인

bash-2.03# unzip -l 142397-01.zip

Archive:  142397-01.zip
 Length    Date    Time    Name
 ------    ----    ----    ----
      0  10-23-09  00:09   142397-01/
     76  07-21-09  07:13   142397-01/.diPatch
    214  07-21-09  07:13   142397-01/patchinfo
   2664  10-23-09  00:09   142397-01/README.142397-01
      0  07-21-09  07:57   142397-01/SUNWlibsasl/
      0  07-21-09  07:57   142397-01/SUNWlibsasl/reloc/
      0  07-21-09  07:57   142397-01/SUNWlibsasl/reloc/usr/
      0  07-21-09  07:57   142397-01/SUNWlibsasl/reloc/usr/lib/
      0  07-21-09  07:57   142397-01/SUNWlibsasl/reloc/usr/lib/sparcv9/
 129680  07-21-09  07:41   142397-01/SUNWlibsasl/reloc/usr/lib/sparcv9/libsasl.so.1
 113152  07-21-09  07:41   142397-01/SUNWlibsasl/reloc/usr/lib/libsasl.so.1
    560  07-21-09  07:57   142397-01/SUNWlibsasl/pkginfo
    627  07-21-09  07:57   142397-01/SUNWlibsasl/pkgmap
      0  07-21-09  07:57   142397-01/SUNWlibsasl/install/
    565  07-21-09  07:13   142397-01/SUNWlibsasl/install/patch_preinstall
  12100  07-21-09  07:13   142397-01/SUNWlibsasl/install/postinstall
   4300  07-21-09  07:13   142397-01/SUNWlibsasl/install/patch_postinstall
   8023  07-21-09  07:13   142397-01/SUNWlibsasl/install/preinstall
   2044  07-21-09  07:13   142397-01/SUNWlibsasl/install/patch_checkinstall
   4104  07-21-09  07:13   142397-01/SUNWlibsasl/install/u.none
   7102  07-21-09  07:13   142397-01/SUNWlibsasl/install/i.none
   3426  07-21-09  07:13   142397-01/SUNWlibsasl/install/copyright
   6488  07-21-09  07:13   142397-01/SUNWlibsasl/install/checkinstall
  18488  06-03-09  04:12   142397-01/LEGAL_LICENSE.TXT
 ------                    -------
 313613                    24 files

* 파일 추출
bash-2.03# unzip 142397-01.zip 142397-01/README.142397-01

Archive:  142397-01.zip
  inflating: 142397-01/README.142397-01
bash-2.03#
반응형
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

2008. 9. 21. 17:47 Unix/Shell

null copy

○ null copy
        File의 Size를 0으로 만드는 작업으로 일반적으로 로그파일이 커졌을 때 해당 파일의 사이즈를 초기화하는 목적
        등으로 사용됨.

○ 방법
        1. cat /dev/null > FILENAME
                 /dev/null 파일을 직접 파일에 Redirection한다.
                일반적인 경우 사용됨.
                 예)
                    # cat /dev/null > /var/log/messages

        2. > FILENAME
                직접 Redirection해서 파일에 쓴다.
                Bourne Shell, Korn Shell에서 사용됨
                예)

                    # > /var/log/messages


참고 원문
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                             UNIX GURU UNIVERSE
                                UNIX HOT TIP

                       Unix Tip 3151 - September 21, 2008

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

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

NULL IT FAST

Here is the fastest way to truncate a file to zero
bytes in a bourne or korn shell.

$ > /var/log/messages

This is a good method, if the file has to be truncated,
but is opened by another process. For example, if you
want to truncate /var/log/messages, which is held
open by syslogd...

반응형
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

최근에 올라온 글

최근에 달린 댓글

글 보관함