1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

A script to delete the X first chars of a .txt file

Discussion in 'Other Languages' started by peet69, Apr 3, 2011.

  1. peet69

    peet69 Newbie

    Joined:
    Dec 26, 2010
    Messages:
    48
    Likes Received:
    8
    hello,

    im looking for a script or something similar, which deletes the first X (1,2,3 or more, should be configurable) chars of a .txt file.

    basically the .txt file looks like this

    Code:
    1. http://xxxxxxx
    2. http://xxxxxxx
    .....
    123. http://xxxxxxx
    .....
    8171. http://xxxxxxx
    
    and after using the script it should be only

    Code:
    http://xxxx
    i already tried to google, but did not found anything.

    help would be really appreciated, thanks
     
  2. sensitiveheart_4

    sensitiveheart_4 Power Member

    Joined:
    Sep 21, 2007
    Messages:
    563
    Likes Received:
    128
    Location:
    New Delhi, India
    Im also looking for something like that
     
  3. cooooookies

    cooooookies Senior Member

    Joined:
    Oct 6, 2008
    Messages:
    1,008
    Likes Received:
    216
    very simple with linux awk / gawk
     
  4. jkr500

    jkr500 Regular Member

    Joined:
    Apr 3, 2009
    Messages:
    239
    Likes Received:
    42
    you can use excel for this also.
     
  5. sensitiveheart_4

    sensitiveheart_4 Power Member

    Joined:
    Sep 21, 2007
    Messages:
    563
    Likes Received:
    128
    Location:
    New Delhi, India
    I dont have linux

    Any other solution ?
     
  6. bezopravin

    bezopravin BANNED BANNED

    Joined:
    May 11, 2010
    Messages:
    461
    Likes Received:
    3,471
    You can do it easily in Notepad++

    Look at this video : http://www.blackhatworld.com/blackhat-seo/2378886-post12.html

    Hope this helps...
     
    • Thanks Thanks x 2
  7. sensitiveheart_4

    sensitiveheart_4 Power Member

    Joined:
    Sep 21, 2007
    Messages:
    563
    Likes Received:
    128
    Location:
    New Delhi, India
    @bezopravin,

    Can i do this with notepad 2 ?
     
  8. bezopravin

    bezopravin BANNED BANNED

    Joined:
    May 11, 2010
    Messages:
    461
    Likes Received:
    3,471
    Nope. Notepad doesn't have that function. You can download Notepad++ for free http://download.tuxfamily.org/notepadplus/5.9/npp.5.9.Installer.exe
     
    • Thanks Thanks x 1
  9. sensitiveheart_4

    sensitiveheart_4 Power Member

    Joined:
    Sep 21, 2007
    Messages:
    563
    Likes Received:
    128
    Location:
    New Delhi, India
    thanks alot bud
     
  10. Autumn

    Autumn Elite Member

    Joined:
    Nov 18, 2010
    Messages:
    2,197
    Likes Received:
    3,041
    Occupation:
    I figure out ways to make money online and then au
    Location:
    Spamville
    If you're looking for another option, save this file as edit_text.php and upload it to one of your domains, then go to that url in your browser. It gives you a text box; paste your text into the box and click submit, it will delete everything before the http:// on each line.

    Code:
    <?php
    
    if($_POST['save'] == 'yes') {
    	$text = $_POST['current'];
    	$text = explode("\n", $text);
    	foreach($text as $line) {
    		$line = preg_replace('/.*http/', 'http', $line);
    		$output .= "$line\n";
    	}
    
    	echo "<pre>
    $output
    </pre>
    ";
    
    	exit;
    }
    
    
    echo '<html>
    <head>
    <title>Edit text</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta name="robots" content="noarchive">
    <link rel="stylesheet" type="text/css" href="style.css" />
    </head>
    <body>
    Post your text in here:<br>
    <form action="'. $_SERVER['PHP_SELF'] .'" method="post">
    <textarea rows="30" cols="110" name="current" wrap="off">
    </textarea><br>
    <br>
    <input type="hidden" name="save" value="yes">
    <input type="submit" name="submit" value="Save">
    </form>
    <br>
    </body>
    </html>';
    
    ?>
    
     
    • Thanks Thanks x 5
  11. blackhit

    blackhit Super Moderator Staff Member Jr. VIP Premium Member

    Joined:
    Jan 28, 2008
    Messages:
    2,402
    Likes Received:
    4,251
    Location:
    Dark Side Of The Moon
    There are 2 texteditors that should be in your basic toolkit.
    Not only for this specific problem but for all kinds of text manipulation.

    Notepad++ (as bezopravin recommended)

    and

    Textmaster
    Code:
    http://www.nontube.com/products/text-master/
    Both are free.
     
    • Thanks Thanks x 2