Search Results

Search: Posts Made By: Lucas_0418
6,800
Posted By Lucas_0418
Hi Alister, Thanks for your reply, let me...
Hi Alister,
Thanks for your reply, let me realize that the while - read loop is totally unnecessary, I made the problem more complicated, since it is so simple. and you are very right that...
1,936
Posted By Lucas_0418
Hi , The codes run successfully in my...
Hi ,
The codes run successfully in my cygwin environment, and I am sorry that I can't get any more test environment in weekend.
What's your environment , OS ? awk version ?
And I...
1,936
Posted By Lucas_0418
Hi guy, try this and may it could work.$...
Hi guy,
try this and may it could work.$ echo '1001 000 HEADER
1001 001 RAJESH
1001 002 100
1001 002 200
1001 002 500
1001 006 FOOTER
1002 000 HEADER
1002 001 RAMESH
1002 002 100
1002...
1,639
Posted By Lucas_0418
I'm sorry to hear that, the 'find' in your OS...
I'm sorry to hear that, the 'find' in your OS must frustrated you..

Are you able to touch some file in the directory that you are monitoring ?
If so, you could run your script via cron every...
11,635
Posted By Lucas_0418
Sorry clippertm, I think the problem of...
Sorry clippertm,
I think the problem of output all occurences is that we used the wildcard *.*
so maybe we must use sort after grep
Or use perl or awk as apmcd47 say, u know, both...
11,635
Posted By Lucas_0418
Sorry clippertm, I made a mistake, delete...
Sorry clippertm,
I made a mistake, delete the double plus.
grep -h '4=[745-755]' *.* | grep '3078=' | sort -u -t'|' -k2,2?
If [745-755] is not available, use this:
grep -h...
Forum: Programming 03-20-2014
2,556
Posted By Lucas_0418
Hi guy, this is a method to get your...
Hi guy,
this is a method to get your desired output, and it is modified from your code, may help u
awk '$1*1000%50==0{if($1/0.05>cnt){for(i=cnt;i<$1/0.05;i++){printf "%-8s %-8s\n", ...
1,461
Posted By Lucas_0418
Hi Scrutinizer, Thanks for reminding me,...
Hi Scrutinizer,
Thanks for reminding me, when I was coding, I felt that I am missing something like bound check, but when I saw the result is correct and there is another thing disturbed me...
1,461
Posted By Lucas_0418
Founded that your need a minimum number, it...
Founded that your need a minimum number, it frustrated me.
$ awk '{a[NR]=$0}$2=="1"{p=s+1;s=NR;for(i=p;i<=s;i++){if(p==1){print a[i]","s-i}else{x=i-p+1<s-i?i-p+1:s-i;print a[i]","x}}}' FS=',' file...
5,825
Posted By Lucas_0418
Hi guy, try this: awk...
Hi guy,
try this: awk '{for(i=1;i<=NF;i++){a[i]=a[i]?a[i]"|"$i:$i}}
END{for(i=1;i<=length(a);i++){split(a[i],b);printf i;for(m in b){c[b[m]]++}for(n in c){printf "|"n"="c[n]}printf "\n";delete...
1,163
Posted By Lucas_0418
Hi Scrutinizer, Thanks Scurtinizer, thanks...
Hi Scrutinizer,
Thanks Scurtinizer, thanks for your advice.
\{1,\} is not nessesary, a [[:blank:]] is totally enough, the sed code is better after you edited it.
1,163
Posted By Lucas_0418
Hi guy, Try this: sed -n...
Hi guy,
Try this:
sed -n '/^a[[:blank:]]\{1,\}/{N;/\nb[[:blank:]]\{1,\}/p;D}'

cheers.
4,161
Posted By Lucas_0418
Hi guy, As anbu123 said, if your data is...
Hi guy,
As anbu123 said, if your data is sorted, you code is correct.
Mostly we do this to select non-duplicate records
awk '!a[$1]++' inputfile
1,721
Posted By Lucas_0418
Hi popeye, '>>' redirect may can not used...
Hi popeye,
'>>' redirect may can not used to a variable instead of a file.
If need to saves all 5 of the subs execution responses in a var or an array.

This codes may works.

Array:...
1,682
Posted By Lucas_0418
Hi Akshay, In s/\$/RS/gg means global...
Hi Akshay,
In s/\$/RS/gg means global substitution. and 's' is the command.

And this is when g is a command.
g Copy/append hold space to pattern space



Sorry guy, see you have...
1,682
Posted By Lucas_0418
Hi guy, $ is an anchor point to the end of a...
Hi guy,
$ is an anchor point to the end of a line in regular expression
Use \$
1,218
Posted By Lucas_0418
When you are in the command mode. Input these ...
When you are in the command mode.
Input these
:g/^aternqaco\./d
1,842
Posted By Lucas_0418
Hi, I did some modification with your code. ...
Hi, I did some modification with your code.
Now it may works as you want, but may not all of the columns could format print beautifully.
And I must go to sleep now~
Good night.
mkdir result...
9,451
Posted By Lucas_0418
Do not filter the files with extensions ...
Do not filter the files with extensions

#!/usr/bin/perl -w
use warnings;
my $source_dir="/home/EDISON/test";
opendir(DIR, $source_dir) or die;
my @allfiles = grep {$_ ne '.' and $_ ne '..'...
12,791
Posted By Lucas_0418
If you do not mind to grep four times, this may...
If you do not mind to grep four times, this may could help you.

TP=`grep -c "1[[:blank:]]\{1,\}1$" infile`
TN=`grep -c "0[[:blank:]]\{0,\}0$" infile`
FN=`grep -c "0[[:blank:]]\{0,\}1$" infile`...
2,161
Posted By Lucas_0418
Hi, may you double check that you have modified...
Hi, may you double check that you have modified this part of your code with chacko193's advice
if [ "$i"="puma" ]; then
the space " " between [ and "$i"
and the space " " between "puma" and ]
...
10,026
Posted By Lucas_0418
Hi, looks like your environment is so different...
Hi, looks like your environment is so different with me.
For your code, I find that once $_=<> executed, the very first line would be deleted.
So may you try this?
perl -pi.orig -e '$/=undef;...
Showing results 1 to 22 of 22

 
All times are GMT -4. The time now is 11:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy