Search Results

Search: Posts Made By: lucasvs
1,684
Posted By Don Cragun
No. With my script you need the END clause to...
No. With my script you need the END clause to print the trailing <newline>; with spacebar's script you need the END clause to print the entire last line.
Until you hit EOF, you don't know that...
1,684
Posted By spacebar
Try this: awk '/^1_/{if (x)print...
Try this:
awk '/^1_/{if (x)print x;x="";}{x=(!x)?$0"|":x$0;}END{print x;}'
1,327
Posted By Scrutinizer
FILENAME is a built-in variable but it would not...
FILENAME is a built-in variable but it would not be useful here, as it contains the name of the current input file, in this case "input.tab" ..
5,566
Posted By elixir_sinari
Try awk ' BEGIN{OFS=FS="|"} { ...
Try


awk '
BEGIN{OFS=FS="|"}
{
if(NF>max) max=NF
for(i=1;i<=NF;i++)
{
start=match(a[i],$i)
if(start && substr(a[i],(start+RLENGTH),1) ~ /^[,]*$/)
continue
if(a[i])
...
5,566
Posted By elixir_sinari
Try this: awk -F\| 'BEGIN{OFS=FS}...
Try this:

awk -F\| 'BEGIN{OFS=FS} {start=match(a[$1],$2);if(start && substr(a[$1],(start+RLENGTH),1) ~ /^[,]*$/) next; if(a[$1]) a[$1]=a[$1]","$2; else a[$1]=$2} END{for(i in a) print i,a[i]}' file
3,371
Posted By Scrutinizer
Try: #!/usr/bin/awk -f BEGIN{FS=OFS="|"} ...
Try:
#!/usr/bin/awk -f

BEGIN{FS=OFS="|"}

function convert (n, v,w,x,y,r1,r10,r100,r1000){
split("I II III IV V VI VII VIII IX",r1," ")
split("X XX XXX XL L LX LXX LXXX XC",r10," ")
...
4,564
Posted By agama
I guess you have your reasons, but I don't see...
I guess you have your reasons, but I don't see the point of an array of sequential numbers.


awk '
BEGIN {
for( i = 1; i <= 10000; i++ )
numbers[i] = i;
}
4,718
Posted By Scrutinizer
You would need to do something like this to shift...
You would need to do something like this to shift the fields:
awk '{for(i=1; i<=NF; i++) if($i=="") for(j=i;j<=NF;j++)$j=$(j+1)}1' FS=\| OFS=\| infile
output:
1|2|3|4|5|6||
But that still leaves...
20,805
Posted By CarloM
Carlo@CRM-MT4 ~ $ echo "||AAAA 1 2.; AAAA...
Carlo@CRM-MT4 ~
$ echo "||AAAA 1 2.; AAAA 3.|AAAA 5 6.||" | awk '{print gensub (/([^[:blank:]]+[[:blank:]]+[[:digit:]]+[[:blank:]]+[[:digit:]]+)[^.;\|]*/,"\\1","g")}'
||AAAA 1 2.; AAAA 3.|AAAA 5...
6,318
Posted By complex.invoke
awk -F'|' '{for(i=3; i<=NF; ++i) print...
awk -F'|' '{for(i=3; i<=NF; ++i) print $1FS$2FS$i}'
20,805
Posted By CarloM
Well, they worked on your original example :p. ...
Well, they worked on your original example :p.

EDIT:
Try:
Carlo@CRM-MT4 ~
$ echo "AAAA 1 2 f45 iop 234-RT.; AAAA 123 456 gf kuygb 2iuygb.; AAAA 678 89 wer4k lh8." |
> awk '{print gensub...
7,483
Posted By balajesuri
awk -F'|' '{print $0"|"$2}' inputfile
awk -F'|' '{print $0"|"$2}' inputfile
2,135
Posted By Scrutinizer
There is one closing brace missing. It may be...
There is one closing brace missing. It may be that your input file differs from your sample, for example, when it contains some tabs instead of spaces. What happens when you cut and paste your...
8,322
Posted By balajesuri
This will check for the largest length in every...
This will check for the largest length in every column and will space accordingly.

perl -F'\t' -lane '
BEGIN {
open I, "< inputfile";
for (<I>) {
chomp;
@x = split...
8,322
Posted By itkamaraj
nawk -F"\t"...
nawk -F"\t" 'BEGIN{b=0}{for(i=1;i<=NF;i++){a=length($i);if(a>b)b=a;}}END{print b}' input.txt
the above awk will give the longest field in your file.

after that you can pass that value to awk...
1,830
Posted By balajesuri
Yes, you can start with perl -F'\t' -lane '.....
Yes, you can start with perl -F'\t' -lane '.....
1,830
Posted By balajesuri
perl -lane '@x=split /,/,$F[1]; print...
perl -lane '@x=split /,/,$F[1]; print "$F[0]\t$_\t$F[2]" for(@x)' inputfile
1,830
Posted By bartus11
Try: awk -F"\t" -vOFS="\t"...
Try: awk -F"\t" -vOFS="\t" '{n=split($2,a,",");for (i=1;i<=n;i++) print $1,a[i],$3}' file
4,950
Posted By Scrutinizer
the join command concatenates, so: print join...
the join command concatenates, so:
print join ("\t", $-[1]+1 . "-" . $+[1] , @F )
4,950
Posted By Scrutinizer
Try: perl -F\\t -lane 'if ($F[5] =~...
Try:
perl -F\\t -lane 'if ($F[5] =~ s/.*?([13]{1,5}tomatoes[13]{1,5}).*/$1/p) {print join ("\t", @F, $-[1]+1 . "-" . $+[1] )}' infile
4,950
Posted By Scrutinizer
You are selecting on the sixth column instead of...
You are selecting on the sixth column instead of the second column in the example of the starting post, so then you need to replace F[1] with F[5] and are these fields tab separated? Slight...
4,950
Posted By balajesuri
awk splits the line into fields based on...
awk splits the line into fields based on whitespaces by default. So $2 is not "bb11 toma toes 111b bbbbb" but just "bb11". Tell awk to split fields based on tab '\t' and then $2 would be what you...
4,834
Posted By itkamaraj
In the MAC OSX, can you try the below sed ...
In the MAC OSX, can you try the below sed


sed "s/[[:<:]]$a[[:>:]]/$b/g"
4,834
Posted By itkamaraj
if you use single quote in the sed ' then,...
if you use single quote in the sed '

then, it will not evaluate the $a and $b values.

so, it search for $a and replce it to $b
8,929
Posted By ctsgnb
ls -1
ls -1
Showing results 1 to 25 of 29

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