|
|
|
||||
|
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() |
|
|||||||
| Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
|
Thread Tools |
|
|
#1 |
|
Confirmed User
Join Date: Oct 2002
Posts: 6,780
|
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?
__________________
_________________ I am the best
|
|
|
|
|
|
#2 |
|
Now choke yourself!
Industry Role:
Join Date: Apr 2006
Posts: 12,085
|
for n in `cat file`; do echo $n":lolsox" >> file.new; done
__________________
|
|
|
|
|
|
#3 |
|
Now choke yourself!
Industry Role:
Join Date: Apr 2006
Posts: 12,085
|
sed 's/$/:lolsox/g' file > file.new
__________________
|
|
|
|
|
|
#4 |
|
(felis madjewicus)
Industry Role:
Join Date: Jul 2006
Location: In Mom & Dad's Basement
Posts: 20,368
|
someone who writes code daily should be able to whip something up in a couple minutes.
|
|
|
|
|
|
#5 |
|
Now choke yourself!
Industry Role:
Join Date: Apr 2006
Posts: 12,085
|
awk ' { print $0":lolsox" } ' file > file.new
__________________
|
|
|
|
|
|
#6 |
|
Confirmed User
Join Date: Jun 2009
Location: Asheville, NC
Posts: 2,277
|
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...
__________________
ICQ: 258-202-811 | Email: eric{at}bestxxxporn.com |
|
|
|
|
|
#7 |
|
Now choke yourself!
Industry Role:
Join Date: Apr 2006
Posts: 12,085
|
Code:
<?php // PHP4monkeyz
$l = file('file');
$n='';
foreach ($l as $ln => $line) {
echo "Doin da line #{$ln}.\n";
$n .= $line."lolsox";
}
$f = @fopen('file.new, 'w');
if (!$f) {
die("I can't be writin no files mothafuccka.\n");
} else {
$b = fwrite($f, $data);
fclose($f);
echo "I done writ ". ($b/1024) . "kB, yo.\n";
}
?>
__________________
|
|
|
|
|
|
#9 | |
|
Confirmed User
Join Date: Oct 2002
Posts: 6,780
|
Quote:
tried that.. get Parse error: syntax error, unexpected T_STRING in /home/psmail/public_html/safelocals.com/test/append.php on line 8
__________________
_________________ I am the best
|
|
|
|
|
|
|
#10 |
|
Now choke yourself!
Industry Role:
Join Date: Apr 2006
Posts: 12,085
|
That one was the joke.
This one works though: Code:
<?php // PHP4monkeyz
$l = file('file');
$n='';
foreach ($l as $ln => $line) {
echo "Doin da line #{$ln}.\n";
$n .= rtrim($line) . "lolsox" . "\n";
}
$f = fopen('file.new', 'w');
if (!$f) {
die("I can't be writin no files mothafuccka.\n");
} else {
$b = fwrite($f, $n);
fclose($f);
echo "I done writ ". ($b/1024) . "kB, yo.\n";
}
?>
__________________
|
|
|
|
|
|
#11 |
|
Now choke yourself!
Industry Role:
Join Date: Apr 2006
Posts: 12,085
|
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";?>
__________________
|
|
|
|