Visit Our UNIX and Linux User Community

Search Results

Search: Posts Made By: danmero
1,248
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,055
Posted By danmero
awk '/\"/{for(i=2;i<=NF;i+=2){print $i}}' FS=\" ...
awk '/\"/{for(i=2;i<=NF;i+=2){print $i}}' FS=\" file
1,801
Posted By danmero
Base on your data sample try the following...
Base on your data sample try the following one-liner
awk 'END{for(l=1;l++<NF;)print o[l]}{for(l=I;l++<NF;){o[l]=((o[l])?o[l]FS:S)$l}}' file


Since this is your first post please read and...
1,169
Posted By danmero
awk '/^2011-12-26 14:37/,/^2011-12-26 14:58/' file
awk '/^2011-12-26 14:37/,/^2011-12-26 14:58/' file
904
Posted By danmero
awk -F\> '/^#/{_=$NF}{sub(/^seq/,_)}_' file
awk -F\> '/^#/{_=$NF}{sub(/^seq/,_)}_' file
1,375
Posted By danmero
awk...
awk '/^#/{++c}NF{file="file"c".file_prod_reg";print $0 > file}' file
5,774
Posted By danmero
awk 'BEGIN{FS=OFS="|"}{$11="word1";$12="word2"}1'...
awk 'BEGIN{FS=OFS="|"}{$11="word1";$12="word2"}1' file
1,034
Posted By danmero
Using parameter expansion in bash 4.x ...
Using parameter expansion in bash 4.x
today=$(date)
today="${today^^}"
1,402
Posted By danmero
for i in *.syl;do echo $(<$i) ${i%.*};done We...
for i in *.syl;do echo $(<$i) ${i%.*};done
We don't need UUoC
12,423
Posted By danmero
awk 'BEGIN{FS=OFS="|"}{y=$6!=x?0:y;x=$6}$5=++y'...
awk 'BEGIN{FS=OFS="|"}{y=$6!=x?0:y;x=$6}$5=++y' file
12,423
Posted By danmero
awk -F\| '$5=NR' OFS=\| file
awk -F\| '$5=NR' OFS=\| file
1,338
Posted By danmero
awk 'NR==1 || /#END/{f--;next}/#START/{print...
awk 'NR==1 || /#END/{f--;next}/#START/{print x;f++;next}f' file
1,713
Posted By danmero
# awk -F'[ |]' '{for(i=0;++i<=NF;){if($i){printf...
# awk -F'[ |]' '{for(i=0;++i<=NF;){if($i){printf $i ((i==NF)?ORS:($i~"the|ke")?OFS:"|")}}}' file
1|2|3|test|james|ke the one|value
1|2|3|test|the value|comp
1|2|3|test|james|value...
1,692
Posted By danmero
df -k "$fs" | awk 'NR==2 {print int($4) }' ...
df -k "$fs" | awk 'NR==2 {print int($4) }'
should do the job :rolleyes:
1,638
Posted By danmero
awk -F"[./]" '$1=$1' file ;)
awk -F"[./]" '$1=$1' file
;)
1,489
Posted By danmero
awk 'NR==FNR{a[$2]=$0;next}{print...
awk 'NR==FNR{a[$2]=$0;next}{print a[$1]?a[$1]:"ABSENT"}' file1 file2
1 a rew sdf ghd 234 gfd 345
ABSENT
7 c dns esd lkn 765 nkc 093
4 d bhj asd klj 231 kljn 211
ABSENT
3 f hjk kln ghj 879 nkj...
939
Posted By danmero
Let's try this one: awk -v x=0 '$1==x{print...
Let's try this one:
awk -v x=0 '$1==x{print NR}' file
27
2,966
Posted By danmero
Ops, first answer was wrong ;) awk...
Ops, first answer was wrong ;)
awk 'BEGIN{FS=OFS=","}{x=split($2,a," ");for(i=0;++i<=x;){$2=a[i];print}}' file
2,112
Posted By danmero
awk ' BEGIN {OFS="\t\t";while(getline <...
awk ' BEGIN {OFS="\t\t";while(getline < "file2"){m[$1]=$2;n[$1]=$3}}{m[$1]+=$2;n[$1]+=$3}{print $1,m[$1],n[$1]}' file1
or using sort at the end
awk 'BEGIN{OFS="\t\t"}END{for(i in a) print...
1,078
Posted By danmero
Sorry, I'm not the one :rolleyes: however you can...
Sorry, I'm not the one :rolleyes: however you can take a look at http://wiki.bash-hackers.org/syntax/pe
1,466
Posted By danmero
awk -vVar="linux from the text"...
awk -vVar="linux from the text" 'tolower($0)~Var{print NR}' file > new.file
2,314
Posted By danmero
awk 'BEGIN{FS=OFS="|"}END{p($0,z)}function...
awk 'BEGIN{FS=OFS="|"}END{p($0,z)}function p(y,z){print y z}{$NF=_;if(NR-1 && P!=$0){p(P,z);z=0};P=$0;z++}' file
199|TST-GURGAON|GURGAON|9
1|TST - MAIN LAB|DELHI|3
333|TST-PREET VIHAR|DELHI|4...
1,085
Posted By danmero
echo entry1 entry2 entry3 entry4 |awk...
echo entry1 entry2 entry3 entry4 |awk '{for(;++i<=NF;)$i=$i FS $i}1'
2,439
Posted By danmero
awk -F'[ =,]'...
awk -F'[ =,]' '/^dn:/{x=$3;y=$0;next}/^mail:/{sub(x,$NF,y);$0=y ORS$0}1' file
2,218
Posted By danmero
For a disordered list i'll opt for: awk -F[.=]...
For a disordered list i'll opt for:
awk -F[.=] '!NF{next}$(NF-1)=="user"{x=$NF;sub($(NF-1)"="$NF,y);a[$0]=x}$(NF-1)=="password"{x=$NF;sub($(NF-1)"="$NF,y);if(a[$0])b[$0]=x}a[$0] && b[$0]{print...
Showing results 1 to 25 of 114

 

Featured Tech Videos

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