Search Results

Search: Posts Made By: jethrow
2,075
Posted By jethrow
Try a > && < instead of == in the awk...
Try a > && < instead of == in the awk statement.
2,075
Posted By jethrow
Here's an option, assuming there's no spaces in...
Here's an option, assuming there's no spaces in the file names:find . -type f -mtime -1 -printf '%f %TH%TM\n' | awk '$NF=="1845" {print $1}'
1,603
Posted By jethrow
Instead of using sequentially named variables,...
Instead of using sequentially named variables, why not use a list (if you don't need to start with 19), or a dict?child = {}
child[19] = 'value 19'
child[20] = 'value 20'

for x in range(19,20):...
1,665
Posted By jethrow
... if perl is an option:perl -0777 -pe...
... if perl is an option:perl -0777 -pe 's/==Image Gallery==.?<gallery>.*?<\/gallery>\s?//gs' file
9
2,194
Posted By jethrow
Here's another option:join -t'~' -v1 <(sed...
Here's another option:join -t'~' -v1 <(sed 's/\t/~/2' file1|sort) file2 | tr '~' '\t'

EDIT:join -t'~' -v1 <(sed 's/ /~/2' file1|sort) file2 | tr '~' ' '
1,524
Posted By jethrow
Based on your given input & desired output,...
Based on your given input & desired output, couldn't you just use:join -t',' file1 file2
3,964
Posted By jethrow
awk ' $2=="CD" { key=$5"|"$9"|"; ...
awk '
$2=="CD" {
key=$5"|"$9"|";
($3>A[key"max"] || A[key"max"]=="")? A[key"max"]=$3:"";
($4>A[key"max"] || A[key"max"]=="")? A[key"max"]=$4:"";
($3<A[key"min"] || A[key"min"]=="")?...
1,399
Posted By jethrow
awk ' NR%2 {match($0,/ [0-9]+ /);...
awk '
NR%2 {match($0,/ [0-9]+ /); n=substr($0,RSTART,RLENGTH); next}
{print $0, n}
' file
7,564
Posted By jethrow
Another option would be to just check the...
Another option would be to just check the filename:awk '
BEGIN {f=FILENAME}
FILENAME==f {A[$1]; f=FILENAME; next}
($1 in A)
' file1 file2

The ultra-short-code-hackers can even use:awk '...
1,639
Posted By jethrow
awk -F, '{print "totalamount :"$1, "Count:" $2}'...
awk -F, '{print "totalamount :"$1, "Count:" $2}' OFS='\n' file
1,423
Posted By jethrow
awk -F'|' 'NR==FNR {split($5,a,","); for(i in a)...
awk -F'|' 'NR==FNR {split($5,a,","); for(i in a) {A[a[i]]++; $5=a[i]; print $0 >> "file.tmp"}} NR!=FNR && (FNR==1 || A[$5]>1)' OFS='|' file file.tmp && rm file.tmp
2,654
Posted By jethrow
... on a side note, the ternary isn't...
... on a side note, the ternary isn't necessary:awk '/^@/{s=/192\.2\.3/}s' file
7,323
Posted By jethrow
It's worth noting that Don's example won't match...
It's worth noting that Don's example won't match if inside the quotes a comma is the first character. Since \K doesn't seem to work with the VB Regexp object, you could utilize a look-ahead assertion...
7,323
Posted By jethrow
So why ask for help in a UNIX/Linux forum? ...
So why ask for help in a UNIX/Linux forum?

Anyways, as Don already pointed out, Parsing based on double quotes is what I'd do. But, if you want just a strait regex solution, the following needle...
923
Posted By jethrow
Please post some concrete requests. You keep...
Please post some concrete requests. You keep changing the source data. Or, better yet, how about learning from the posted code & adapting it to meet your needs?
923
Posted By jethrow
Remove the red line to keep the dots, rather than...
Remove the red line to keep the dots, rather than dashes:
perl -F'\s|,' -ane '$\=",";
for $i (0..$#F) {
@s=split(/:/,$F[$i]);
if($i<=1) {
$s[0]=~s/\./-/g;
print $s[0].($i==1?...
982
Posted By jethrow
awk 'NR==FNR {a[$1]=$2; next} $1 in a {print $0,...
awk 'NR==FNR {a[$1]=$2; next} $1 in a {print $0, a[$1]}' file2 file1
1,189
Posted By jethrow
also ...for i in `seq 1 $n`; do echo $i; done......
also ...for i in `seq 1 $n`; do echo $i; done... though you don't need the 1 since you're starting at 1.
1,006
Posted By jethrow
$line=~/.*,(.*?\w)-\w/; print "$1\n"
$line=~/.*,(.*?\w)-\w/; print "$1\n"
4,470
Posted By jethrow
For my reference ... ... can you provide an...
For my reference ...
... can you provide an example?

... what would be the threshold? Would gawk perform better?
4,470
Posted By jethrow
awk 'NR>1 {print > (OFN=FILENAME"."(NR-1));...
awk 'NR>1 {print > (OFN=FILENAME"."(NR-1)); close(OFN)}' RS="--dump[^\n]*" file

EDIT:
... implemented this above ...
1,766
Posted By jethrow
... a basic awk approach ...awk ' ...
... a basic awk approach ...awk '
$0~/IN:CTRL=/ {f="I"; i++}
$0~/OUT:CTRL=/ {f="O"; o++}
f=="I" {IN[i]=IN[i] RS $0}
f=="O" {OUT[o]=OUT[o] RS $0}
END {for (n in IN)
print...
1,460
Posted By jethrow
... another option ...| cut -c10- | tr -d _
... another option ...| cut -c10- | tr -d _
14,089
Posted By jethrow
... could utilize awk, which natively handles...
... could utilize awk, which natively handles floats:b=`echo $1|awk '{print $0*.43}'`

... my bad, missed the second page where this had been resolved ...
2,863
Posted By jethrow
perl -ne ' if(m/User@Host/){s/\s//g;...
perl -ne '
if(m/User@Host/){s/\s//g; if($.>1){print "\n"}; print "$_ | "}
elsif((@m = m/\w+:\s\w+/g) && (0+@m>2)){print join(" | ",@m) }
else {chomp; print " | $_"}
' file
Showing results 1 to 25 of 47

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