1611 shaares
17 private links
17 private links
4 results
tagged
line
# Loading from __DATA__
my @hosts = <DATA>;
chomp @hosts;
# => ["coucou.com", "coco.com", "cici.com", "chichi.com", "cucu.com", "cece.com" ]
__DATA__
coucou.com
coco.com
cici.com
chichi.com
cucu.com
cece.com
# Loading from file ./hosts
use Mojo::File;
my $file = Mojo::File->new('hosts');
my @hosts = grep { $_ ne '' } grep { $_ !~ m/^#/ } split '\n', $file->slurp;
# => ["coucou.com", "coco.com", "cici.com", "chichi.com", "cucu.com", "cece.com" ]
# ./hosts
# Deals with comments and blank lines
coucou.com
coco.com
# More hosts
cici.com
chichi.com
cucu.com
cece.com
Try query-replace
enter
[ space ]
enter
M-j
enter
!
enter
To remove the line and print the output to standard out:
sed '/pattern to match/d' ./infile
To directly modify the file (with GNU sed):
sed -i '/pattern to match/d' ./infile