subject="apply multiple regex to each line"

R

Ralf Müller

hi out there,
i wanted to $subject of a file. For a single regex, i used perl (ok, that's my fault):
perl -pi -e '<regex>' file

but for $subject i did something like
ruby -e 'p gets.gsub(....).gsub(....).gsub(....) while gets' file

is there an equivalent expression in perl?
And, does anyone know a smart expression to delete lines, which only contain any kinds of spaces?

Till now i use:
ruby -e 'puts readlines.to_s.gsub(/\n{2,}/,"\n").split(/\n/)' eddi-bef.dump > 1table

Thanks
ralf
 
R

Robert Klemme

Ralf Müller said:
hi out there,
i wanted to $subject of a file. For a single regex, i used perl (ok, that's my fault):
perl -pi -e '<regex>' file

but for $subject i did something like
ruby -e 'p gets.gsub(....).gsub(....).gsub(....) while gets' file

is there an equivalent expression in perl?

That's a Perl question, which is probably better answered in a Perl NG.
And, does anyone know a smart expression to delete lines, which only
contain any kinds of spaces?

egrep -v '^[[:space:]]*$' said:
Till now i use:
ruby -e 'puts readlines.to_s.gsub(/\n{2,}/,"\n").split(/\n/)'
eddi-bef.dump > 1table

Much more efficient:

ruby -n -e 'print $_ unless /^\s*$/' eddi-bef.dump > 1table

robert
 
M

Martin DeMello

Ralf Müller said:
And, does anyone know a smart expression to delete lines, which only
contain any kinds of spaces?

Till now i use:
ruby -e 'puts readlines.to_s.gsub(/\n{2,}/,"\n").split(/\n/)' eddi-bef.dump > 1table

ruby -ne 'print unless /^\s*$/' file

or

ruby -pe 'next if /^\s*$/' file

martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,186
Latest member
vinaykumar_nevatia

Latest Threads

Top