Search Results

Search: Posts Made By: agama
5,311
Posted By Don Cragun
There are a few problems here. If this script is...
There are a few problems here. If this script is in the directory where you are looking for and changing occurrences of "./x.mak", one of the files it will try to modify is itself (in at least two...
2,025
Posted By Don Cragun
Hi agama, When I tried your scripts, the...
Hi agama,
When I tried your scripts, the headers came out fine, but all of the data fields were zero:
x_a, A, BX, C,DYY, E, F, G, H, I, J
1_a, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
2_a, ...
66,364
Posted By Chubler_XL
@agama, don' think ksh supports the substring...
@agama, don' think ksh supports the substring expansion and certainly bash will evaluate the length field so ${infile:0:len-4} is acceptable.
Forum: Programming 10-26-2012
25,123
Posted By alister
Then what you read is either a pedagogical...
Then what you read is either a pedagogical simplification or an oversight. Since the statement, "free() doesn't return memory to the system", is true for 4.4BSD [see Note 1], and since The Design and...
3,048
Posted By aix_admin_007
works great
works great.

Thanks.
2,061
Posted By dodgerfan78
agama, Thanks. I ran that command as you...
agama,

Thanks. I ran that command as you suggested and it gave back no input. I am using a spreadsheet editor to make the CSV file so I am positive that there is data in column 7 for every row. It...
866
Posted By Chubler_XL
You can take advantage of the fact that awk...
You can take advantage of the fact that awk automatically prints given a true expression to reduce the complexity:

awk '$2<0.5{$2="0.50"} $2<1.0' file1 > file2
1,685
Posted By Scrutinizer
sed -E uses ERE, so it should know alternation: ...
sed -E uses ERE, so it should know alternation:
sed -E 's/abc=123([^0-9]|$)/abc=999\1/g'
1,252
Posted By Don Cragun
agama said he found a # by itself on a line as...
agama said he found a # by itself on a line as the section separator. When I copied the sample input and fed it through od -cb, I found that the separator line contained the octal byte values 343,...
2,940
Posted By spacebar
Either one of these should give you the counts...
Either one of these should give you the counts your looking for:
sort -u -k1,1 -k3,3 t | cut -d' ' -f3 | awk '{a[$2]++} END{for(e in a){print e FS a[e]}}'
sort -u -k1,1 -k3,3 t | cut -d' ' -f3 |...
24,168
Posted By Don Cragun
No. What you say is true for a BRE; not for an...
No. What you say is true for a BRE; not for an ERE. Quoting from IEEE Std. 1003.1-2008, P190, L6174-6183:
2,988
Posted By Don Cragun
Of the rcp(1) man pages listed on this site, only...
Of the rcp(1) man pages listed on this site, only the Solaris man page specifies exit codes. That man page also has the following warning:

Your function looks OK, but it can't work if the command...
1,733
Posted By chihung
In Solaris, /usr/bin/grep does not support -q...
In Solaris, /usr/bin/grep does not support -q flag. Try to use /usr/xpg4/bin/grep, see man page for details.

You need to test the return status ($?) for the /usr/xpg4/bin/grep 'cos it does not...
3,353
Posted By Scrutinizer
Another option maybe: awk -F\| '/ 500$|...
Another option maybe:
awk -F\| '/ 500$| 202$/{if($13 in A)print A[$13] RS $0; else A[$13]=$0}' infile | sort -t\| -k3,3n



--
@agama:
awk: calling undefined function asort
input record...
1,054
Posted By alister
That's a one-liner in name only. In the future,...
That's a one-liner in name only. In the future, please use a reasonable coding style instead of such a long line. It will make your code easier for novices to understand, and members not using a 2560...
1,860
Posted By alister
Looks like there's a little bit more to it than...
Looks like there's a little bit more to it than that. Fields 2 and 3 need to be cut. I suppose you can pipe cut into sed or just do it in sed itself.

Regards,
Alister
8,187
Posted By alister
It's never a good idea to withhold information....
It's never a good idea to withhold information. Better too much than too little. I've lost count of how many times I've seen someone ask for help on some very specific task, and then, later add...
3,045
Posted By bash4ever
That's awesome. Thank you so much. ...
That's awesome. Thank you so much.

---------- Post updated at 07:54 AM ---------- Previous update was at 07:49 AM ----------

@ agama, there was just one little typo:

is:
printf( "%10s %10s...
1,380
Posted By alister
A much less readable and maintainable version of...
A much less readable and maintainable version of agama's solution which is guaranteed to make whoever inherits the code mutter under their breath:

awk -F_ '!a[$1] && !a[$2] && ++a[$1] && ++a[$2]'...
8,843
Posted By Scrutinizer
Slight modification to agama's suggestion.. Try: ...
Slight modification to agama's suggestion.. Try:
grep -vxf whitelist.txt source.txt

--edit--
OK, I see the original post got changed in the mean time...

Try:
grep -vwf whitelist.txt...
4,242
Posted By alister
If you want to ensure that the script has been...
If you want to ensure that the script has been given a viable working directory, then $1 should be tested to confirm that it's non-empty and a directory. In that instance, blindly substituting a...
3,180
Posted By methyl
date +%s (seconds since the epoch) is also a GNU...
date +%s (seconds since the epoch) is also a GNU extra to the date command.

The simplest way is to work from data +%U (week number in the year). Using mathematics appropriate to your Shell,...
4,543
Posted By Chubler_XL
Oops something seems to be missing here try: ...
Oops something seems to be missing here try:

#!/bin/sh

if [ `date +%d` -eq `cal | awk '$NF{E=$NF} END{printf E}'` ]
then
rm /home/user/tst/logs/* && rm /home/user/tst/stats/*
fi
exit 0
1,929
Posted By mirni
Well that was not very constructive. Here...
Well that was not very constructive.

Here you go:

awk '
NR==1{ printf("%20s\t%10s\t%10s\n", $1,"+ve Cr","-ve Cr")}
NR>1{ if($2>0) sumPos[$1] += $2;
else sumNeg[$1] += $2;
...
4,011
Posted By Chubler_XL
awk -vSECS=60 '$(NF-1)+0 > SECS { exit 3}'...
awk -vSECS=60 '$(NF-1)+0 > SECS { exit 3}' file.csv
[ $? -eq 3] && mutt ....
Showing results 1 to 25 of 108

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