Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.


copy from pattern to the enf of file

copy from pattern to the enf of file

I'm sorry to post this probably very simple question ...
I need to copy from a file into another from the line with pattern '123' to the end of the file.
I know how to do it from pattern1 to pattern2 :
awk '/pattern1/,/Pattern2/' /${File1} >> ${File2}

but I need something like
awk '/pattern1/,EOF' /${File1} >> ${File2}

Thank you !!!

RE: copy from pattern to the enf of file

Thanks !
awk solution doesn't seem to work.
But sed did the job !

RE: copy from pattern to the enf of file


Quote (cbsm)

I know how to do it from pattern1 to pattern2 :
awk '/pattern1/,/Pattern2/' /${File1} >> ${File2}
So the range starts on the line where matching the first expression results true, and stops on the line where matching the second expression results true.

Now your goal is that range never ends ( at least not before the file ends ). So just use a second expression which never evaluates to true.

The simplest is to hardcode a false value as second expression ( in AWK 0 and "" are false values ) :

CODE --> command line

awk '/pattern1/,0' /${File1} >> ${File2} 
Tested with gawk, mawk and original awk.

( By the way, PHV's AWK code works for me with the above enumerated interpreters. )


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close