Search Results

Search: Posts Made By: danmero
10,736
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
4,754
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,394
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,576
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.
2,279
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...
120,148
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}'
83,328
Posted By danmero
or AWK awk '{print substr($0,(length($0)-3))}'...
or AWK
awk '{print substr($0,(length($0)-3))}' FILE
1,450
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
1,165
Posted By danmero
awk -F\> '/^#/{_=$NF}{sub(/^seq/,_)}_' file
awk -F\> '/^#/{_=$NF}{sub(/^seq/,_)}_' file
27,412
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,631
Posted By danmero
awk...
awk '/^#/{++c}NF{file="file"c".file_prod_reg";print $0 > file}' file
6,546
Posted By danmero
awk 'BEGIN{FS=OFS="|"}{$11="word1";$12="word2"}1'...
awk 'BEGIN{FS=OFS="|"}{$11="word1";$12="word2"}1' file
1,355
Posted By danmero
Using parameter expansion in bash 4.x ...
Using parameter expansion in bash 4.x
today=$(date)
today="${today^^}"
1,836
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
14,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
14,423
Posted By danmero
awk -F\| '$5=NR' OFS=\| file
awk -F\| '$5=NR' OFS=\| file
1,584
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,903
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,705
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...
2,808
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,173
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,122
Posted By danmero
awk -F"[./]" '$1=$1' file ;)
awk -F"[./]" '$1=$1' file
;)
3,362
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,363
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,805
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

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