http://sial.org/howto/perl/one-liner/#s2
# 기본기 잡기 위해서는 한번쯤 보면 좋은 사이트
http://www.unixguide.net/unix/perl_oneliners.shtml
# 유투브 동영상 Perl One-liner로 다운 받는 방법
http://www.catonmat.net/blog/downloading-youtube-videos-with-a-perl-one-liner/
# Perl One-liner는 아니지만 유용한 책을 소개
http://aero.sarang.net/blog/2009/03/-perl-4.html
# Perl One-liner 을 배우기전에 꼭 한번 봤으면 하는 자료
http://gypark.pe.kr/wiki/Perl/%EC%A0%95%EA%B7%9C%ED%91%9C%ED%98%84%EC%8B%9D
# Perl을 배우기 위해서 이정도 문서는 읽어줘야 하지 않을 까요?^^
http://doc.perl.kr/twiki/bin/view/Wiki/HowToStartPerl#시작하기
수많은 Cpan을 자랑으로 OOP 언어라는 인식하기를....
Perl그리고grep한다 지정한 문자열을 포함한 행을 추출
원 라이너
관련
grep(을)를 실현한다원 라이너(커멘드 prompt(으)로부터 사용한다)
perl -ne "print if ( /search/ )" inputfile.txt > outputfile.txt
inputfile.txt
search1 kjhkh search2 lkjlkjl oiuyyiu search3
원 라이너란
-e
- -e(을)를 지정하면, 그 후에 계속 된다Perl스크립트가 직접 실행된다.
-n
- -n(을)를 지정하면, 그 후에 계속 된다Perl스크립트가,while(<>){ }그리고 둘러싸인 것이 된다.
원 라이너 해설
- perl -ne "print if( /search/ )" inputfile.txt > outputfile.txt
- 이 문장은 이하의,1,2 (와)과 같다.
1: grep.pl
while(<>){ # ←인수로 주어진 파일의 각 행이,<>에게 건네진다. # <>그리고 받은 각 행은, 루프 속에서,$_에게 건네진다. print if( /search/ ); # ←정규 표현//에는,$_하지만 암묵적으로 이용된다 # print의 인수에는, 암묵적으로$_하지만 이용된다. }
2: 실행
perl grep.pl inputfile.txt > outputfile.txt
Windows의커멘드 prompt그리고cat한다
커멘드 prompt로cat( 파일의 결합 )(을)를 하려면 이하와 같이 합니다.
perl -ne "print" file1 file2 file3 > output.txt
'Perl > Perl OneLine' 카테고리의 다른 글
| [Perl] Perl One-liner 모음 (0) | 2010/02/02 |
|---|---|
| [Perl] Perl Command-Line Options (0) | 2009/04/09 |
| [Perl] 원라인 Perl[디렉토리 안에 문자열을 찾아 각 월별 건수 확인] (4) | 2009/03/26 |


