Skip to main content
added 1 character in body
Source Link
ilkkachu
  • 148.2k
  • 16
  • 268
  • 441

OK I have decided to write an answer besides a comment.

You can use the i command of sed like:

sed -i '1i \ # The latest IANA port assignments can be gotten from\ # http://www.iana.org/assignments/port-numbers\ # The Well Known Ports are those from 0 through 1023.\ # The Registered Ports are those from 1024 through 49151\ # The Dynamic and/or Private Ports are those from 49152 through 65535\ #\ # Each line describes one service, and is of the form:\ #\ # service-name port/protocol [aliases ...] [# comment]' file 

The is for GNU sed. For sed on Macs you need to use sed -i''i '' -e ..., and for POSIX sed there is no simple way to do things in place.

OK I have decided to write an answer besides a comment.

You can use the i command of sed like:

sed -i '1i \ # The latest IANA port assignments can be gotten from\ # http://www.iana.org/assignments/port-numbers\ # The Well Known Ports are those from 0 through 1023.\ # The Registered Ports are those from 1024 through 49151\ # The Dynamic and/or Private Ports are those from 49152 through 65535\ #\ # Each line describes one service, and is of the form:\ #\ # service-name port/protocol [aliases ...] [# comment]' file 

The is for GNU sed. For sed on Macs you need to use sed -i'' -e ..., and for POSIX sed there is no simple way to do things in place.

OK I have decided to write an answer besides a comment.

You can use the i command of sed like:

sed -i '1i \ # The latest IANA port assignments can be gotten from\ # http://www.iana.org/assignments/port-numbers\ # The Well Known Ports are those from 0 through 1023.\ # The Registered Ports are those from 1024 through 49151\ # The Dynamic and/or Private Ports are those from 49152 through 65535\ #\ # Each line describes one service, and is of the form:\ #\ # service-name port/protocol [aliases ...] [# comment]' file 

The is for GNU sed. For sed on Macs you need to use sed -i '' -e ..., and for POSIX sed there is no simple way to do things in place.

Source Link
Weijun Zhou
  • 3.6k
  • 22
  • 50

OK I have decided to write an answer besides a comment.

You can use the i command of sed like:

sed -i '1i \ # The latest IANA port assignments can be gotten from\ # http://www.iana.org/assignments/port-numbers\ # The Well Known Ports are those from 0 through 1023.\ # The Registered Ports are those from 1024 through 49151\ # The Dynamic and/or Private Ports are those from 49152 through 65535\ #\ # Each line describes one service, and is of the form:\ #\ # service-name port/protocol [aliases ...] [# comment]' file 

The is for GNU sed. For sed on Macs you need to use sed -i'' -e ..., and for POSIX sed there is no simple way to do things in place.