Search Results

Search: Posts Made By: pareshkp
1,168
Posted By rdrtx1
awk ' NR==1 {r1c1=$1; r1c2="P"; for (i=3;...
awk '
NR==1 {r1c1=$1; r1c2="P"; for (i=3; i<=NF; i++) orows[orc++]=$i; next;}
{
if (!times[$1]) times[tmc++]=$1; times[$1]=$1;
if (!pcols[$2]) cols[cc++]=$2; pcols[$2]=$2;
for (i=3; i<=NF;...
1,039
Posted By RudiC
Your output sample seems to miss the L1 column...
Your output sample seems to miss the L1 column values. However, tryawk '
BEGIN {OFS = FS = ","}
FNR == NR {H[$0] = NR
HI[NR] = $0
MX = NR...
1,641
Posted By danmero
Hi Don Cragun, your solution is simpler and run...
Hi Don Cragun, your solution is simpler and run 30% faster that my. Thanks.
1,641
Posted By Don Cragun
Hi pareshkp, You might also want to try a...
Hi pareshkp,
You might also want to try a slightly simpler awk script:
awk -F'[<=>]' '{printf("%s%s",$(NF-2),(NR%5)?(NR%5==1)?" ":";":ORS)}' Input

which with your sample input produces the...
1,956
Posted By Don Cragun
You're wrong. RudiC is correct. As an example,...
You're wrong. RudiC is correct. As an example, on OS X version 10.11.3 the command:
printf '%s\n' 1 2 3|awk '{a[$1]}END{for(i in a)print i}'

produces the output:
2
3
1
Using a different...
1,956
Posted By RudiC
That doesn't preserve the desired sequence of...
That doesn't preserve the desired sequence of columns for longer lists. man awk: Small adaption:awk '
BEGIN {OFS = FS = ","}
FNR == NR {h[$0] = NR
MX = NR
...
1,641
Posted By MasWag
With sed, like this cat input.xml | tr -d...
With sed, like this

cat input.xml | tr -d "\n" | sed 's:</d><pokl>\|$:\n:g;' | sed 's/^.*GBNo=//;s:</pokl><d>: :;s:</d><d>:;:g;s:</d>::;'
2,097
Posted By RudiC
Can't you do it on your own?
Can't you do it on your own?
2,097
Posted By RudiC
Your output does NOT reflect the input data; e.g....
Your output does NOT reflect the input data; e.g. Z / L1 should be 15, not 100. Try awk ' {LN[$1]; HD[$2]; MX[$1,$2]=$3}
END { printf "%10s", "ID"; for (i in HD)...
1,370
Posted By RudiC
Any attempt from your side? ---------- Post...
Any attempt from your side?

---------- Post updated at 17:16 ---------- Previous update was at 17:14 ----------

Howsoever, tryawk '
NR==1 {T=$0
gsub (/_[^_ ]*($|...
1,307
Posted By Scrutinizer
OK, try: awk '$3~/^:/{s=$3}{$3=s OFS $3}1'...
OK, try:
awk '$3~/^:/{s=$3}{$3=s OFS $3}1' OFS='\t' file
3,857
Posted By RavinderSingh13
Hello PareshKP, I don't think so code posted...
Hello PareshKP,

I don't think so code posted in POST#2 will substitute all the strings Hello, in a single file, here is an example for same.

cat Input_file
Hello A B C
X 1 2 3
Hello 4 5 6...
3,857
Posted By RavinderSingh13
Hello pareshkp, Could you please try...
Hello pareshkp,

Could you please try following and let me know if this helps.

awk '(NR==1 && $1=="Hello"){sub("Hello","Byee",$0);} 1' Input_file
Output will be as follows.

Byee A B C
X 1...
1,708
Posted By neutronscott
zip stores paths relative to current directory....
zip stores paths relative to current directory. so one solution is to change the directory.


( cd /var/rt/on/mg/set/XM/Swor/xt && zip "$HOME/EM/ZIPData/All.zip" 0300* )
1,081
Posted By RavinderSingh13
Hello disedorgue, If Number of fields are...
Hello disedorgue,

If Number of fields are less than 6 and last 2 columns have values A and C so above solution will work then
also(which I guess pareshkp doesn't want seems user want to...
1,081
Posted By disedorgue
Hi, A awk solution: $ cat finput.data ...
Hi,
A awk solution:
$ cat finput.data
DD142 0_1 DD142_A DD142_B A B
DD142 1_1 DD142_B DD142_C B C
DD142 2_1 DD142_A DD142_C A C
DD142 3_1 DD142_A A
DD142 3_2 DD142_A A
DD142 4_1 DD142_B ...
2,055
Posted By Akshay Hegde
Also try : awk -F'[><=]' '/^<moid/{k=1;...
Also try :

awk -F'[><=]' '/^<moid/{k=1; if(p)print p; p=$6}k && /^<r/{p=p OFS $3}END{print p}' infile

-- edit--

With header

awk -F'[><=]' 'FNR==1{print...
2,055
Posted By RavinderSingh13
Hello pareshkp, Following may hepl you also...
Hello pareshkp,

Following may hepl you also in same.


awk 'BEGIN{OFS="\t";print "UC" OFS "pmct1" OFS "pmNo2" OFS "pmNo3S"} /\<moid\>/...
2,055
Posted By blackrageous
This works... awk -fx.awk <input-xml-file> ...
This works...

awk -fx.awk <input-xml-file>

where x.awk contains....


BEGIN {printf("%-10s%-10s%-10s%-10s\n","UC","pmct1","pmNo2","pmNo3S")}
/<moid>/ {
split($0,A,"=");...
1,634
Posted By RavinderSingh13
Hello Akshay, Nice code :b:, in 2nd code I...
Hello Akshay,

Nice code :b:, in 2nd code I guess there is no need to use $3 part in this code, it may work as follows too.


awk '{n=split($8,A,/=/); $8 = mode ? A[n] : "\b"; }1' FS=';'...
1,634
Posted By Akshay Hegde
$ awk '{n=split($8,A,/=/); $8 = mode ? A[n] :...
$ awk '{n=split($8,A,/=/); $8 = mode ? A[n] : "\b"; $3 = mode ? $3 : A[n] }1' FS=';' OFS=';' mode='0' file
So;C951;1;2;0;100;true;473;12;EEE
So;C951;4;2;0;100;true;481;12;EEE


$ awk ...
1,634
Posted By RavinderSingh13
Hello pareshkp, Following may help. ...
Hello pareshkp,

Following may help.

1st requirement solution:

awk -F";" '{gsub(/.*\=/,X,$(NF-3));print}' OFS=";" Input_file


Output will be as follows.
...
1,252
Posted By RavinderSingh13
Hello pareshkp, kindly use the following. ...
Hello pareshkp,

kindly use the following.


awk '{if($3 !~ /dev/){gsub(/p|d.*/,X,$3)} else {gsub(/p.*t\_+|\_.*/,Y,$3)}} 1' filename


Output will be as follows.


P081 wr1 120...
814
Posted By RavinderSingh13
Hello Pareshkp, Following may help. ...
Hello Pareshkp,

Following may help.


awk -F"/" '{print $1 OFS $3}' OFS="/" filename > Output_file


Output will be as follows.


cat Output_file

000100/port_0_dev_7...
1,443
Posted By blackrageous
something like... count=$(wc -l file1.xml |...
something like...

count=$(wc -l file1.xml | cut -f1 -d' ')
(( count = count - 3 ))
head -${count} file1.xml

count=$(wc -l file2.xml | cut -f1 -d' ')
(( count = count - 3 ))
tail -${count}...
Showing results 1 to 25 of 60

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