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

2007. 11. 3. 20:59 Unix

확장자 바꾸기

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                             UNIX GURU UNIVERSE
                                UNIX HOT TIP
 
                       Unix Tip 2334 - May 23, 2006
 
                   http://www.ugu.com/sui/ugu/show?tip.today
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
확장자 바꾸기
 
여러 파일들의 확장자를 변경하고자 할때 다음의 명령어로는 수행할 수 없다.
 
       % mv *.abc *.def
 
하지만 다음 쉘 스크립트를 이용하여 원하는 작업을 하는데 사용할 수 있다.
 
***
 
다음 쉘 스크립트를 이용하면 확장자가 .abc인 파일(*.abc)을 모두
확장자가 .def인 파일(*.def)변경할 수 있다.
 
#!/bin/sh
for f in *.abc; do
    mv $f `basename $f .abc`.def
done
 
스크립트가 어떻게 작동하는지 살펴보자.
 
for f in *.abc; do
 
.abc로 끝나는 파일을 찾아 순서대로 파일명을 $F에 대입한다.
 
 mv $f `basename $f.abc`.def
 
`basename $f .abc`는 $f의 파일명을 받아 따라오는 .abc를 떼어내고,
.def를 앞의 결과에 덧붙이면 결과적으로 명령은 다음과 같이 된다.
 
"mv file.abc file.def"
 
done
 
위의 "for" 루프를 종료한다.
 
"csh" 또는 "tcsh"에서 위의 작업을 하려면 다음과 같이 할 수 있다.
 
foreach f in ( *.abc )
   mv $f `basename $f .abc`.def
end
 
----------------------------------------------------------
 
CHANGE THE SUFFIX
 
If you want to change the suffix of multiple files, you can't do:
 
       % mv *.abc *.def
 
However the following shell script can be used to do the required
opperation:
 
***
 
Change all *.abc file to *.def the following shell script would work:
 
#!/bin/sh
for f in *.abc; do
 mv $f `basename $f .abc`.def
done
 
How it works:
 
 for f in *.abc; do
 
Set up a look for all files ending in .abc, and each time around setup
$f as the filename
 
 mv $f `basename $f.abc`.def
 
`basename $f .abc` takes the filename in $f and removes any trailing
occurences of .abc, we then append .def to the result and the resulting
command becomes
"mv file.abc file.def"
 
  done
 
Ends the "for" loop above.
 
Under "csh" or "tcsh" a similar thing could be done with:
 
 foreach f in ( *.abc )
   mv $f `basename $f .abc`.def
 end
 
This tip generously supported by: pwain@liberate.com
반응형
Posted by She쥐포s
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
                             UNIX GURU UNIVERSE
                                UNIX HOT TIP

                       Unix Tip 2333 - May 22, 2006

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

GREP을 이용하여 빈줄 지우기

awk에 익숙하지 않지만 단순 아스키 파일에서 빈줄을 지우는 빠르고 쉬운 방법을
원하는 사람들은 'grep'과 결합하여 'cat'을 사용하는 것이 효과적인 방법이다.

cat file1 | grep -v '^$' >file2
mv -f file2 file1

----------------------------------------------------------------------

DELETING BLANK LINES USING GREP

For thos who are not familiar with
awk, but still want a quick and easy
way of removing blank lines from a
flat ascii file, remember that the
use of 'cat' in conjuction with
'grep' is just as effective.

cat file1 | grep -v '^$' >file2
mv -f file2 file1
반응형
Posted by She쥐포s

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

달력

 « |  » 2024.5
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 31

최근에 올라온 글

최근에 달린 댓글

글 보관함