Skip to main content
edited tags
Link
ilkkachu
  • 148k
  • 16
  • 268
  • 441

How to appendadd lines/text to the beginning of a file

how How to append lines/text to the beginning of a file

tcpmux 1/tcp # TCP port service multiplexer tcpmux 1/udp # TCP port service multiplexer rje 5/tcp # Remote Job Entry rje 5/udp # Remote Job Entry echo 7/tcp echo 7/udp discard 9/tcp sink null discard 9/udp sink null systat 11/tcp users systat 11/udp users daytime 13/tcp daytime 13/udp qotd 17/tcp quote qotd 17/udp quote msp 18/tcp # messageMessage send protocol (historic) msp 18/udp # messageMessage send protocol (historic) chargen 19/tcp ttytst source chargen 19/udp ttytst source 

So that the file will look like:

# 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] tcpmux 1/tcp # TCP port service multiplexer tcpmux 1/udp # TCP port service multiplexer rje 5/tcp # Remote Job Entry rje 5/udp # Remote Job Entry echo 7/tcp echo 7/udp discard 9/tcp sink null discard 9/udp sink null systat 11/tcp users systat 11/udp users daytime 13/tcp daytime 13/udp qotd 17/tcp quote qotd 17/udp quote msp 18/tcp # messageMessage send protocol (historic) msp 18/udp # messageMessage send protocol (historic) chargen 19/tcp ttytst source chargen 19/udp ttytst source 

The simple solution is to copy the original file to file.bck and then, append the new lines to the file and then, and append file.bck to the file.

butBut this isn't an elegant solution.

how to append lines/text to the beginning of file

tcpmux 1/tcp # TCP port service multiplexer tcpmux 1/udp # TCP port service multiplexer rje 5/tcp # Remote Job Entry rje 5/udp # Remote Job Entry echo 7/tcp echo 7/udp discard 9/tcp sink null discard 9/udp sink null systat 11/tcp users systat 11/udp users daytime 13/tcp daytime 13/udp qotd 17/tcp quote qotd 17/udp quote msp 18/tcp # message send protocol (historic) msp 18/udp # message send protocol (historic) chargen 19/tcp ttytst source chargen 19/udp ttytst source 

So that the file will look like

# 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] tcpmux 1/tcp # TCP port service multiplexer tcpmux 1/udp # TCP port service multiplexer rje 5/tcp # Remote Job Entry rje 5/udp # Remote Job Entry echo 7/tcp echo 7/udp discard 9/tcp sink null discard 9/udp sink null systat 11/tcp users systat 11/udp users daytime 13/tcp daytime 13/udp qotd 17/tcp quote qotd 17/udp quote msp 18/tcp # message send protocol (historic) msp 18/udp # message send protocol (historic) chargen 19/tcp ttytst source chargen 19/udp ttytst source 

The simple solution is to copy the original file to file.bck and then append the new lines to the file and then append file.bck to the file

but this isn't elegant solution

How to append lines/text to the beginning of a file

tcpmux 1/tcp # TCP port service multiplexer tcpmux 1/udp # TCP port service multiplexer rje 5/tcp # Remote Job Entry rje 5/udp # Remote Job Entry echo 7/tcp echo 7/udp discard 9/tcp sink null discard 9/udp sink null systat 11/tcp users systat 11/udp users daytime 13/tcp daytime 13/udp qotd 17/tcp quote qotd 17/udp quote msp 18/tcp # Message send protocol (historic) msp 18/udp # Message send protocol (historic) chargen 19/tcp ttytst source chargen 19/udp ttytst source 

So that the file will look like:

# 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] tcpmux 1/tcp # TCP port service multiplexer tcpmux 1/udp # TCP port service multiplexer rje 5/tcp # Remote Job Entry rje 5/udp # Remote Job Entry echo 7/tcp echo 7/udp discard 9/tcp sink null discard 9/udp sink null systat 11/tcp users systat 11/udp users daytime 13/tcp daytime 13/udp qotd 17/tcp quote qotd 17/udp quote msp 18/tcp # Message send protocol (historic) msp 18/udp # Message send protocol (historic) chargen 19/tcp ttytst source chargen 19/udp ttytst source 

The simple solution is to copy the original file to file.bck, append the new lines to the file, and append file.bck to the file.

But this isn't an elegant solution.

Language and markup.
Source Link
Kusalananda
  • 356.1k
  • 42
  • 737
  • 1.1k

how to append lines/text fromto the beginning of file

weWe have the following example file:

how toHow may we append thesethe following lines fromto the beginning of the file?

soSo that the file will belook like that

theThe simple solution is to copy the origoriginal file to file.bckfile.bck and then append the new lines to the file and then append the file.bckfile.bck to the file

how to append lines/text from beginning of file

we have the following example file

how to append these lines from beginning of the file

so file will be like that

the simple solution is to copy the orig file to file.bck and then append the new lines to file and then append the file.bck to file

how to append lines/text to the beginning of file

We have the following example file:

How may we append the following lines to the beginning of the file?

So that the file will look like

The simple solution is to copy the original file to file.bck and then append the new lines to the file and then append file.bck to the file

Source Link
yael
  • 14k
  • 72
  • 221
  • 377
Loading