2007. 11. 3. 21:12 Unix

디렉토리 내용 옮기기

디렉토리 내용 옮기기
(Solaris에서.. 다른 Unix도 대동소이함, 리눅스의 경우 S옵션도 있음 찾아볼 것)
 
cd origdir
tar cfb - 126k . | ( cd /newdir ; tar xfvp - )

성능을 위해서는 star가 더 좋다.
ufsdump와 restore에 대해서는 man page를 보라, 매우 비슷한 문법이다.
):
@@@@@@@@@@@@@@@@@@@@[ 원문 ]@@@@@@@@@@@@@@@@@@@@
 
cd origdir
tar cfb - 126k . | ( cd /newdir ; tar xfvp - )

for performance star is better
see man pages for ufsdump+restore, very similar syntax
):
반응형
Posted by She쥐포s

2007. 11. 3. 21:10 Unix

현재 디렉토리 표시

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                             UNIX GURU UNIVERSE
                                UNIX HOT TIP

                       Unix Tip 2342 - May 31, 2006

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

내가 어디 있는가?

csh에서 자신이 어디에 있는지 알고 싶을 때, .cshrc 파일에 다음의 두 줄을 넣어라.

alias sp 'set prompt="`hostname`:`pwd`> "'
alias cd 'cd \!*;sp'

@@@@@@@@@@@@@@@@@@@@[ 원문 ]@@@@@@@@@@@@@@@@@@@@
WHERE AM I ALWAYS

In csh, if you always want to know
where you are, put in your .cshrc-file
the following 2 lines:

alias sp 'set prompt="`hostname`:`pwd`> "'
alias cd 'cd \!*;sp'
반응형
Posted by She쥐포s
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                             UNIX GURU UNIVERSE
                                UNIX HOT TIP
 
                       Unix Tip 2327 - May 16, 2006
 
                   http://www.ugu.com/sui/ugu/show?tip.today
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
cpio로 디렉토리구조(tree) 복사하기
 
표준 Unix tar를 사용하여 디렉토리구조를 복사하게 되면 원래의 복사하는 동안
디렉토리와 파일에 대한 소유자와 그룹정보를 보존하지 않는다.
이 정보를 보존하기 위해서 다음과 같은 방법으로 find(1)와 pipe를 통해
cpio(1)를 사용하라.
 
% cd <원본 디렉토리>
% find . -depth -print | cpio -pudm <대상 디렉토리>
 
이 명령은 <원본 디렉토리>의 디렉토리 구조에 대한 미러 이미지를 <대상 디렉토리>에
생성할 것이다.
 
@@@@@@@@@@@@@@@@@@@@[ 원문 ]@@@@@@@@@@@@@@@@@@@@
 
COPY A TREE WITH CPIO
 
Using standard UNIX tar to copy a
tree doesn't preserve the original
owner and group information for the
directories and files during the copy.
To do this, use find(1) piped to cpio(1)
this way:
 
% cd <source-directory>
% find . -depth -print | cpio -pudm <dest-directory>
 
This will create a mirror image of the
<source-directory> tree in <dest-directory>.
반응형
Posted by She쥐포s
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                             UNIX GURU UNIVERSE
                                UNIX HOT TIP

                       Unix Tip 2330 - May 19, 2006

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

vi에서 파일간 복사하기

다음은 vi 편집기에서 필요한 수의 라인을 한 파일에서 다른 파일로 복사하는 방법이다.
먼저 원본 파일에서 다음의 키 조합을 사용하여라.

ESC키를 누른다.
Shift "(Shift 쌍따옴표)
a키를 누른다.
복사할 라인의 수를 누른다.
yy를 누른다.

이제 :(콜론)을 눌러 vi 프롬프트를 호출한다. 이 상태에서 e 대상파일명을 입력한다.
일단 대상파일이 열리면 복사한 라인들이 삽입될 라인으로 이동한다.

ESC키를 누른다.
Shift "(Shift 쌍따옴표)
a키를 누른다.
p키를 누른다.

라인이 복사되었다.

@@@@@@@@@@@@@@@@@@@@[ 원문 ]@@@@@@@@@@@@@@@@@@@@

VI COPY FILE TO FILE

Here is how to copy the required number
of lines from one file to another in
VI editor.  First use the following
key combinations in the source file.

Press ESCAPE
Press Shift "(Shift double quotes)
Press a
Press the number of lines you want to copy
press y followed by another y

Now press " : " (COLON) to get the vi prompt.
Hit e "Destination file name"
Once you enter the Destination file
go to the line where you want the lines
copied to be inserted.

Press ESCAPE.
Press SHIFT "(Double quotes).
Press a.
Press p.

The lines get copied.
반응형
Posted by She쥐포s

2007. 11. 3. 21:08 Unix

strings 명령어

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                             UNIX GURU UNIVERSE
                                UNIX HOT TIP

                       Unix Tip 2340 - May 29, 2006

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

strings

오브젝트 파일(바이너리 파일)의 내용을 확인하기 위해서 vi 또는 cat 명령을 사용할
수 없다, 그렇게 하기 위해 strings 명령을 사용하라.

%  strings [바이너리 파일명]

명령은 오브젝트 파일에 있는 모든 인쇄 가능한 문자를 화면에 출력할 것이다.
기본적으로 strings 명령은 실행파일의 ASCII 문자를 찾아 화면에 출력한다.
 
core 파일과 다른 바이너리 에러 파일에 유용하다.

@@@@@@@@@@@@@@@@@@@@[ 원문 ]@@@@@@@@@@@@@@@@@@@@

STRINGS - OLD BUT A GOODIE

To check content of an object
file(binary file ) we can't use vi
or cat command, for that use strings
command.

%  strings [name of binary file]

It will print all the printable strings
present in object file.  Basically
strings command looks for ASCII strings
in executable file and print it.

Great for core files and other binary
error files
 
This tip generously supported by: aggarami@pcsbom.patni.com
반응형
Posted by She쥐포s

2007. 11. 3. 21:06 Unix

at으로 매일 실행하기

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                             UNIX GURU UNIVERSE
                                UNIX HOT TIP

                       Unix Tip 2339 - May 28, 2006

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

at으로 매일 실행하기

유닉스는 지정된 시간에 따라 작업을 실행할 수 있는 "at"이라는 명령어를 제공한다.

특정한 작업을 매시간, 매일 실행하기 위해서는 매일 재귀적으로 실행될 수 있는
"at.sh"라는 파일에 다음의 명령어들을 사용하라.

########### CUT HERE ##################

#! /usr/bin/sh

# dt는 현재 날짜를 저장하는데 사용하는 변수

dt=`date | cut -c5-10`

# tm은 현재 시간을 저장하는데 사용하는 변수

tm=`date | cut -c12-13`

while [ $tm -le 23 ]
do

#
"at"은 명령어이고 -f는 특정파일을 실행하는데 사용하는 옵션이다.
# "file Name"은 실행가능한 파일이어야 한다.

    at -f  ./"file Name" $tm $dt
    tm=`expr $tm + 1`
done

#
인위적인 개입없이, 자동으로 다음날의 작업 스케줄을 변경한다.

at -f ./"File Name" 2358 $dt
dt=`expr $dt + 1`
at -f ./at.sh 0002 $dt

########### CUT HERE ##################
 
@@@@@@@@@@@@@@@@@@@@[ 원문 ]@@@@@@@@@@@@@@@@@@@@
 
RUN DAILY WITH AT

UNIX provides a command called "at" which can be used to run jobs according
to the specfied time.

To run a particular job in every hour, every day use the following set of
commands in a file called "at.sh" which will be executed recursively everyday.

########### CUT HERE ##################

#! /usr/bin/sh

# dt is a variable used to store current date

dt=`date | cut -c5-10`

# tm is a variable used to store current time

tm=`date | cut -c12-13`

while [ $tm -le 23 ]
do

# "at" is the command ad -f is the option used to execute a specified
# file. "file Name" should be an executable file.

 at -f  ./"file Name" $tm $dt
 tm=`expr $tm + 1`
done

# With out manual intervention, automatic change over to the next day's job
# scheduling

at -f ./"File Name" 2358 $dt
dt=`expr $dt + 1`
at -f ./at.sh 0002 $dt

########### CUT HERE ##################
반응형
Posted by She쥐포s

2007. 11. 3. 21:05 Unix

숨김파일 찾기

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                             UNIX GURU UNIVERSE
                                UNIX HOT TIP

                       Unix Tip 2338 - May 27, 2006

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

숨김파일 찾기
 
디렉토리에서 숨김파일(.으로 시작하는)만을 찾는다.

ls -a | grep "^\."
 
또는
 
ls -a | awk '$0~/^\./ {print $0}'

@@@@@@@@@@@@@@@@@@@@[ 원문 ]@@@@@@@@@@@@@@@@@@@@

FIND THOSE HIDDEN FILES

Finding only hidden files
(starting with .) in a directory.

ls -a | grep "^\." OR
ls -a | awk '$0~/^\./ {print $0}'
반응형
Posted by She쥐포s

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                             UNIX GURU UNIVERSE
                                UNIX HOT TIP

                       Unix Tip 2337 - May 26, 2006

                   
http://www.ugu.com/sui/ugu/show?tip.today
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
마지막 일요일에 실행하기

매월 마지막 일요일에 작업을 실행하려면, cron으로 다음의 문법을 사용할 있다.

 

18 * * * 0 [`date "+%d"` -gt 24] && /path/to/script

 

이 명령은 일요일 18시에 날짜가 24보다 큰지 체크하여 24보다 크다면 작업을

실행하라(만일 23을 지정하면 작업은 매월 마지막 2 일요일에 실행될 것이다)는

의미이다.


주: date 명령을 감싸고 있는 '`'는 작은 따옴표(')가 아니다.(~와 함께 있는 기호)

=====================================================

RUN ON LAST SUNDAY

If you want a job to run on the last
sunday of every month, you can use
the following syntax from within cron:

18 * * * 0 [`date "+%d"` -gt 24] && /path/to/script

i.e. on sundays at 18:00 check if
the day of the month is greater than
24 - if so run the job (if 23 is
specified the job will run on the last
2 sundays of the month)

NOTE: There back-ticks around the date
command, not single quotes.

This tip generously supported by: duncan.ferguson@egg.com

반응형
Posted by She쥐포s

2007. 11. 3. 21:02 Unix

vi에서 들여쓰기

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                             UNIX GURU UNIVERSE
                                UNIX HOT TIP

                       Unix Tip 2505 - November 10, 2005

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

VI에서 들여쓰기

vi 편집기에서 열을 들여쓰거나 들여쓰기를 제거한다.

<< 1단위 이동폭만큼 현재 라인을 왼쪽으로 이동한다.
>> 1단위 이동폭만큼 현재 라인을 오른쪽으로 이동한다. 

※ 譯者 註 : 리눅스의 vi 및 windows gvim에서 확인한 결과 > 또는 < 숫자만큼
                  이동폭이 변경된다.

이동폭은 다음 명령으로 설정할 수 있다.

:set sw

예를 들면, 이동폭을 4문자로 설정하는 명령은 다음과 같다.

:set sw=4
==============================================================

VI INDENTATION

Indent your lines or remove
the indentation in the vi
editor.

<< Shifts the current line to the left by one shift width.
>> Shifts the current line to the right by one shift width.

You can set the shift width
by command

:set sw

For example, the command to
set the shift width to 4
characters is

:set sw=4

This tip generously supported by:
neetas@noida.hcltech.com
반응형
Posted by She쥐포s

2007. 11. 3. 21:00 Unix

자동 단어 완성기능

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                             UNIX GURU UNIVERSE
                                UNIX HOT TIP
 
                       Unix Tip 2335 - May 24, 2006
 
                   http://www.ugu.com/sui/ugu/show?tip.today
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
자동 단어 완성기능
 
tcsh에서 TAB키는 임의의 응용프로그램(예를 들면 pico, cd, rm, chown등)에 사용될
임의의 이름을 자동으로 완성해준다.(auto complete기능) 또한 root디렉토리(/)부터
절대 경로까지도 자동으로 완성해준다.
 
root(/)로부터 자신의 .cshrc 파일을 열고자 한다면..
 
"pico /ho"[TAB] -> "pico /home/"
계속해서 "you"[TAB] -> "yourusername"
결과적으로 "pico /home/yourusername/"를 얻을 수 있다.
다음으로 ".cs"[TAB] -> ".cshrc"를 얻을 수 있다.
결과적으로 "pico /home/yourusername/.cshrc"를 얻을 수 있다.
상당히 적은 수의 키스트로크로..
 
하지만 yourusername과 yourothername이라는 사용자가 있다고 해보자.
 
그러면 shell이 beep음을 낼 것이며 TAB키를 한번 더 입력하면 "your"로 시작하는
모든 파일 리스트를 보게 될 것이다.
이름이 다른부분에 커서가 위치하게 될 것이며 다른 부분을 입력하고 TAB을 입력하라.
 
이 팁은 명령어에도 작용한다.
 
※ 譯者 註: Linux의 Shell(보통 bash)에서는 기본적으로 지원하는 기능이다.
-------------------------------------------------------
 
AUTO WORD COMPLETION
 
In tcsh, the TAB key will automatically
complete any name in the current
directory for any application (for pico,
cd, rm, chown)... It will even complete
paths from root.
 
Soo... If you want to open your .cshrc
from root you do..
 
"pico /ho"[TAB] -> "pico /home/"
Then continue with "yuo"[tab] -> "yourusername"
Then you get "pico /home/yourusername/"
And then type ".cs"[TAB] -> ".cshrc"
So in the end you get "pico /home/yourusername/.cshrc"
In a lot less stokes...
 
But say there are 2 users called
yourusername and yourothername.
 
Well, then the shell will beep, and if
you hit TAB again, you will get a listing
off all the files that start with "you".
You can then continue to the point where
the names differ, and then hit TAB.
 
This also works for commands.
반응형
Posted by She쥐포s

블로그 이미지
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

최근에 올라온 글

최근에 달린 댓글

글 보관함