News for hackers. Stuff that matters.
Re:Ask HN: What's your favorite little script you've written? by 1vuio0pswjnm7 on Friday July 04, 2025 @01:10AM (#44461292)
A one-liner script for shell output redirection that inserts instead of appends

Typically

   cat file2  >> file1
If want to place file2 at the top of file1 instead of the bottom

   cat file2 file1 > file3
   mv file3 file1
Too much typing, margin for error

The script is called "ins"

   ins file1 < file2
Can also use line number

   ins file1 25 < file2
Inserts file2 at line 25 of file1

One of the most useful scripts I have ever written

Only uses sed or ed

There are no comments on this comment yet.