리눅스 a2p

Jmnote (토론 | 기여)님의 2014년 7월 13일 (일) 09:58 판

1 개요

Awk to Perl translator
리눅스 a2p
/usr/bin/a2p
  • awk 스크립트를 perl 스크립트로 변환하는 리눅스 명령어

2 실습

[root@jmnote ~]# cat hello.awk
#!/bin/awk -f
{print "Hello, world!"}
[root@jmnote ~]# echo '' | ./hello.awk
Hello, world!
[root@jmnote ~]# a2p hello.awk
#!/usr/bin/perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
    if $running_under_some_shell;
			# this emulates #! processing on NIH machines.
			# (remove #! line above if indigestible)

eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift;
			# process any FOO=bar switches

$, = ' ';		# set output field separator
$\ = "\n";		# set output record separator

while (<>) {
    print 'Hello, world!';
}
→ 변환된 결과가 화면에 출력됨
[root@jmnote ~]# a2p hello.awk > hello.pl
[root@jmnote ~]# chmod 755 hello.pl
[root@jmnote ~]# echo '' | ./hello.pl
Hello, world!

3 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}