![]() |
append shit at end of line..
anyone know of a script that will add shit to end of line,
example if my notepad file is: 1.1.1.1 2.2.2.2 i want it to be' 1.1.1.1:80 2.2.2.2:80 anyone know? |
for n in `cat file`; do echo $n":lolsox" >> file.new; done
|
sed 's/$/:lolsox/g' file > file.new
|
someone who writes code daily should be able to whip something up in a couple minutes.
|
awk ' { print $0":lolsox" } ' file > file.new
|
Or if you have a text editor and want to do it manually ...
Find replace \n with :80\n \n is newline btw :P Some editors might want you to use ^n or something... |
Code:
<?php // PHP4monkeyz |
Quote:
|
Quote:
tried that.. get Parse error: syntax error, unexpected T_STRING in /home/psmail/public_html/safelocals.com/test/append.php on line 8 |
Quote:
This one works though: Code:
<?php // PHP4monkeyz |
Just for the hell of it, here's a PHP 4.4+ only inelegant hack:
Code:
<?php echo file_put_contents('file.new', str_replace("\n", "lolsox\n", file_get_contents('file')))?"Worked\n":"Didn't worked\n";?> |
| All times are GMT -7. The time now is 12:50 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123