Sponsored Content
Top Forums Shell Programming and Scripting How to delete characters using a file Post 302357362 by thegeek on Tuesday 29th of September 2009 12:53:01 PM
Old 09-29-2009
Code:
open CFG, "<file.cfg" or die "Unable to open file.cfg";

$hash{10} = 1;

while(<CFG>)  {
    chomp;
    if (length($_) != 1 )  {
        ($a, $b) = /^(.).*(.)$/;
        $hash{ord $_} = 1 for ($a .. $b);
    } else  {
        $hash{ord $_} = 1;
    }
}

while(<>)  {
    foreach (split //, $_)  {
        print if ( $hash{ord $_} );
    }
}


Input:
Code:
hello;*hello;[hello;hello1;{hello1};hello1*

Output:
Code:
hello;hello;hello;hello;hello;hello

 

10 More Discussions You Might Find Interesting

1. Programming

how to insert and delete characters in the middle of file

I have a problem that I want to insert and delete some chars in the middle of a file. fopen() and fdopen() just allow to append at the end. Is there any simple method or existing library that allow these actions? Thanks in advance.:confused: (7 Replies)
Discussion started by: ivancheung
7 Replies

2. UNIX for Dummies Questions & Answers

How to delete a file with special characters

I don't now exactly how I did it, but I created a file named " -C " cexdi:/home1 $ls -lt total 1801336 -rw------- 1 cexdi ced-group 922275840 23 mars 10:03 -C How do I delete this file ? cexdi:/home1 $rm -C rm: invalid option -- C Syntax : rm filename ... Doesn't work...... (5 Replies)
Discussion started by: yveslagace
5 Replies

3. UNIX for Dummies Questions & Answers

delete non printable characters from file

i have a file which contains non printable characters like enter,escape etc i want to delete them from the file (2 Replies)
Discussion started by: alokjyotibal
2 Replies

4. UNIX for Dummies Questions & Answers

how to delete M-^M characters from a file

I am receiving a file with 'M-^M' characters...how do I get rid of these characters. I tried tr -d '\015' and sed '/^M//g', but they didnot work. Appreciate if someone can help me with this (1 Reply)
Discussion started by: hyennah
1 Replies

5. Shell Programming and Scripting

Delete not readable characters

Hi All, I wanted to delete all the unwanted characters in the string. ie, to delete all the characters which are not alpha numeric values. var1="a./bc" var2='abc/\."123' like to get the output as print var1 abc print var2 abc123 Could you guys help me out pls. Your help is... (3 Replies)
Discussion started by: ajilesh
3 Replies

6. Shell Programming and Scripting

Delete new line characters from a file

Hi, I have a file with about 25 colums separated with '~', but few of the lines have extra tabs ('^') and new line characters ('$'). Is there a way I can delete those characters if they are anywhere before the 25th column in a line? example: CLUB000650;12345678;0087788667;NOOP MEMBER ... (4 Replies)
Discussion started by: rudoraj
4 Replies

7. UNIX for Dummies Questions & Answers

Vim help - delete words in a file or characters after pattern

I have a file with words that begin with character #. Whenver that character is found that word should be deleted throughout the file. How do I do that in VIM. e.g: afkajfa ladfa ljafa #222222 kjafad ljl afajkj kjlj uouu #44444 jlkj lkjl Output should be afkajfa ladfa ljafa kjafad... (1 Reply)
Discussion started by: osbourneric
1 Replies

8. Shell Programming and Scripting

how to delete special characters from the file content

Hello Team, Any one suggest how to delte the below special character from a file which is having one column 10 rows of same below content. ---------------------------------------- Kosten|bersicht gemd_ ' =Welche Kosten kvnnen... (2 Replies)
Discussion started by: kanakaraju
2 Replies

9. Shell Programming and Scripting

need to Delete first 10 characters of a file name

Hello Everyone, I need help in deleting first 10 characters from the filename in a directory eg: 1234567890samplefile1.txt 1234567890samplefile2.txt and so on.. need to get the output as samplefile1.txt Thanks in Advance!!!! (8 Replies)
Discussion started by: Olivia
8 Replies

10. UNIX for Advanced & Expert Users

Need help to delete special characters exists only at the end of the each record in UNIX file?

Hi, I have a file in unix with 15 columns.It consists special characters(#,$,^M,@,*,% etc)at the end of the each record.I want to remove these special characters.I used the following: Sed -e 's/ /g;s/ */ /g' . But It is removing special characters exists everywhere in the file(begining,middle... (24 Replies)
Discussion started by: rakeshp
24 Replies
LIBNETCFG(1)						 Perl Programmers Reference Guide					      LIBNETCFG(1)

NAME
libnetcfg - configure libnet DESCRIPTION
The libnetcfg utility can be used to configure the libnet. Starting from perl 5.8 libnet is part of the standard Perl distribution, but the libnetcfg can be used for any libnet installation. USAGE
Without arguments libnetcfg displays the current configuration. $ libnetcfg # old config ./libnet.cfg daytime_hosts ntp1.none.such ftp_int_passive 0 ftp_testhost ftp.funet.fi inet_domain none.such nntp_hosts nntp.none.such ph_hosts pop3_hosts pop.none.such smtp_hosts smtp.none.such snpp_hosts test_exist 1 test_hosts 1 time_hosts ntp.none.such # libnetcfg -h for help $ It tells where the old configuration file was found (if found). The "-h" option will show a usage message. To change the configuration you will need to use either the "-c" or the "-d" options. The default name of the old configuration file is by default "libnet.cfg", unless otherwise specified using the -i option, "-i oldfile", and it is searched first from the current directory, and the from your module path. The default name of new configuration file is "libnet.cfg", and by default it is written to the current directory, unless otherwise speci- fied using the -o option, "-o newfile". SEE ALSO
Net::Config, Net::libnetFAQ AUTHORS
Graham Barr, the original Configure script of libnet. Jarkko Hietaniemi, conversion into libnet cfg for inclusion into Perl 5.8. perl v5.8.0 2003-02-18 LIBNETCFG(1)
All times are GMT -4. The time now is 11:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy