Visit Our UNIX and Linux User Community

Search Results

Search: Posts Made By: danmero
7,976
Posted By danmero
Something like: awk '{a[FILENAME]++}END{for(i...
Something like:
awk '{a[FILENAME]++}END{for(i in a)print i,(a[i]-1)}' * > newfile
3,893
Posted By danmero
awk 'NR==1{x=$0;next}/<\/Order>/{print y RS $0 RS...
awk 'NR==1{x=$0;next}/<\/Order>/{print y RS $0 RS "</OrderDetail>">f}/Order Number/{f="file"++n".xml";y=x}{y=y RS $0}' file.xml
1,036
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,228
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,776
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...
105,145
Posted By danmero
If \n don't work try: $ echo 'foo, bar' | sed...
If \n don't work try:
$ echo 'foo, bar' | sed 's/, /\
/g'
foo
bar
Or awk:
$ echo 'foo, bar' | awk -F', ' '{for(i=1;i<=NF;i++) printf "%s\n", $i}'
77,236
Posted By danmero
or AWK awk '{print substr($0,(length($0)-3))}'...
or AWK
awk '{print substr($0,(length($0)-3))}' FILE
1,161
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
899
Posted By danmero
awk -F\> '/^#/{_=$NF}{sub(/^seq/,_)}_' file
awk -F\> '/^#/{_=$NF}{sub(/^seq/,_)}_' file
21,613
Posted By danmero
Why not shorter ;) # sed 's/./&,/10' file ...
Why not shorter ;)
# sed 's/./&,/10' file
0100159457,Italy Accounts
0100159458,Italy Accounts
0100162198,USA Accounts
1,355
Posted By danmero
awk...
awk '/^#/{++c}NF{file="file"c".file_prod_reg";print $0 > file}' file
5,751
Posted By danmero
awk 'BEGIN{FS=OFS="|"}{$11="word1";$12="word2"}1'...
awk 'BEGIN{FS=OFS="|"}{$11="word1";$12="word2"}1' file
1,020
Posted By danmero
Using parameter expansion in bash 4.x ...
Using parameter expansion in bash 4.x
today=$(date)
today="${today^^}"
1,387
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,311
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,311
Posted By danmero
awk -F\| '$5=NR' OFS=\| file
awk -F\| '$5=NR' OFS=\| file
1,329
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,704
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,481
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...
1,649
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:
927
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
1,616
Posted By danmero
awk -F"[./]" '$1=$1' file ;)
awk -F"[./]" '$1=$1' file
;)
2,953
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,108
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,439
Posted By danmero
awk -vVar="linux from the text"...
awk -vVar="linux from the text" 'tolower($0)~Var{print NR}' file > new.file
Showing results 1 to 25 of 114

 

Featured Tech Videos

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