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.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 08-29-2009, 04:59 PM   #1
xxweekxx
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
xxweekxx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-29-2009, 05:09 PM   #2
GrouchyAdmin
Now choke yourself!
 
GrouchyAdmin's Avatar
 
Industry Role:
Join Date: Apr 2006
Posts: 12,085
for n in `cat file`; do echo $n":lolsox" >> file.new; done
__________________
GrouchyAdmin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-29-2009, 05:10 PM   #3
GrouchyAdmin
Now choke yourself!
 
GrouchyAdmin's Avatar
 
Industry Role:
Join Date: Apr 2006
Posts: 12,085
sed 's/$/:lolsox/g' file > file.new
__________________
GrouchyAdmin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-29-2009, 05:10 PM   #4
Angry Jew Cat - Banned for Life
(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.
Angry Jew Cat - Banned for Life is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-29-2009, 05:11 PM   #5
GrouchyAdmin
Now choke yourself!
 
GrouchyAdmin's Avatar
 
Industry Role:
Join Date: Apr 2006
Posts: 12,085
awk ' { print $0":lolsox" } ' file > file.new
__________________
GrouchyAdmin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-29-2009, 05:13 PM   #6
BestXXXPorn
Confirmed User
 
BestXXXPorn's Avatar
 
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
BestXXXPorn is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-29-2009, 05:17 PM   #7
GrouchyAdmin
Now choke yourself!
 
GrouchyAdmin's Avatar
 
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";
}
?>
__________________
GrouchyAdmin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-29-2009, 05:20 PM   #8
seeandsee
Check SIG!
 
seeandsee's Avatar
 
Industry Role:
Join Date: Mar 2006
Location: Europe (Skype: gojkoas)
Posts: 50,945
Quote:
Originally Posted by GrouchyAdmin View Post
awk ' { print $0":lolsox" } ' file > file.new
lol SOX
__________________
BUY MY SIG - 50$/Year

Contact here
seeandsee is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-29-2009, 05:32 PM   #9
xxweekxx
Confirmed User
 
Join Date: Oct 2002
Posts: 6,780
Quote:
Originally Posted by GrouchyAdmin View Post
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";
}
?>

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
xxweekxx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-29-2009, 05:37 PM   #10
GrouchyAdmin
Now choke yourself!
 
GrouchyAdmin's Avatar
 
Industry Role:
Join Date: Apr 2006
Posts: 12,085
Quote:
Originally Posted by xxweekxx View Post
tried that..
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";
}
?>
This is still godawful code, but it works. Again, It was a joke.
__________________

Last edited by GrouchyAdmin; 08-29-2009 at 05:38 PM.. Reason: It's just really ugly.
GrouchyAdmin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-29-2009, 05:50 PM   #11
GrouchyAdmin
Now choke yourself!
 
GrouchyAdmin's Avatar
 
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";?>
Really, though, everything above works in exactly the same way - find 'end of line' and replace (append) to. Semantically, it's slightly different, but doesn't matter.
__________________
GrouchyAdmin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.