안녕하세요.
문서들의 맨앞에 특정 문자열을 추가하는 일을 하려고 하는데, 문서의 처음을 어떻게
찾으면 좋을지 모르겠습니다.
^가 입력문자열의 처음을 나타내지만, 문서의 처음이라는 보장은 없어서요.
무슨 프로그램 쓰는지 모르겠지만 \A 를 한번 써보세요.
설명은, http://www.regular-expressions.info/reference.html
--------------------Signature-------------------- "What can change the nature of a man?"
#!/usr/bin/perl -w
$file = shift @ARGV; open (FD, $file) || die "Cannot open file $file \n";
my $first=1; while() { if ($first) { $_ =~ s/^/str/; # insert 'str' at the first line $first=0; }
print $_; }
간단하게 쉘이나 펄로 스크립트 하나 짜서.. 리다이렉션 처리 하면..;;;
# ./insert.pl target_file > dest_file ; mv dest_file target_file
그냥 cat으로 하면 안되는 상황인가요?
----- 오늘 나의 취미는 끝없는, 끝없는 인내다. 1973 法頂
텍스트 포맷에 대한 자세한 정보
<code>
<blockcode>
<apache>
<applescript>
<autoconf>
<awk>
<bash>
<c>
<cpp>
<css>
<diff>
<drupal5>
<drupal6>
<gdb>
<html>
<html5>
<java>
<javascript>
<ldif>
<lua>
<make>
<mysql>
<perl>
<perl6>
<php>
<pgsql>
<proftpd>
<python>
<reg>
<spec>
<ruby>
<foo>
[foo]
무슨 프로그램
무슨 프로그램 쓰는지 모르겠지만 \A 를 한번 써보세요.
설명은, http://www.regular-expressions.info/reference.html
--------------------Signature--------------------
"What can change the nature of a man?"
스크립트로... ;;
#!/usr/bin/perl -w
$file = shift @ARGV;
open (FD, $file) || die "Cannot open file $file \n";
my $first=1;
while()
{
if ($first) {
$_ =~ s/^/str/; # insert 'str' at the first line
$first=0;
}
print $_;
}
간단하게 쉘이나 펄로 스크립트 하나 짜서.. 리다이렉션 처리 하면..;;;
# ./insert.pl target_file > dest_file ; mv dest_file target_file
그냥 cat으로 하면
그냥 cat으로 하면 안되는 상황인가요?
-----
오늘 나의 취미는 끝없는, 끝없는 인내다. 1973 法頂
-----
오늘 나의 취미는 끝없는, 끝없는 인내다. 1973 法頂
댓글 달기