How about just using unix grep and word count.
grep -c 'HidePrivacyStatement] t' /some/file/here.config | grep '1$' | wc -l
Definitely, more efficient than making an array and browsing through it.
thanks,
I have bunch of sql files , all have select statements but
semicolon missing at the end of the last lines.
I have written the following sed script to add a semi colon at the end .
file=$1
sed '$d' $file > ${file}.new
sed -n '$p' $file | sed 's/$/ ;/g' >> ${file}.new
mv ${file}.new $file
I...
Thanks a lot Miller for such a nice explanation.
You have a deep understanding of PERL and more importantly,
thanks for sharing. Thats really nice of you.
Thanks Miller,
But in a way presence of g (global) is making or behave like and right ?
Without g it would have simply remove space at beginning only not at the end .
Pl correct if I inferred it wrong.
Hi,
The following regex removes white space from head and tail of the line.
perl -pe 's/^\s+|\s+$//g'
How come it removes both ? It should just remove front because of presence of or (|).
Looking it in boolean context, remove space from front or remove space from end.
The first substitution...
Thanks guys,
Miller, I tried perl -n and it does the job but
BUt why perl -p is also printing non-matching lines ?
The following works but it also prints non-matching lines
perl -pe 'if ($_ =~ /^$/) {$_ = "This is a blank line \n" }' blank.dat
Output :
Hello
This is a blank line
Second...
Hi Guys,
I am trying to print blank lines on using perl command line.
cat blank.dat
Hello
### Blank line commented for visibility ####
Second Blank Line
### Blank line commented for visibility ####
Command 1 :
perl -npe 'if ($_ == m/^$/) {print "This is a blank line \n"}' blank.dat
Output...
Hi All,
Can anyone explain the following perl code implemented as
a part of KSH script ?
It increments the counter for env_var but where is the loop ? Is it a special syntax ?
# abc.ksh
perl -e
$ENV{env_var}++;
do
abc.pl > abc.dat
thanks
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.