Search Results

Search: Posts Made By: cabrao
1,106
Posted By Yoda
Use an awk program to parse your xml. E.g: awk...
Use an awk program to parse your xml. E.g:
awk -F'[<>]' -v V=39786 ' /<ID>/ && $3 == V {
f = 1;
next;
} /<DeviceIDList/ && f {
...
1,519
Posted By Scrutinizer
If sorted: awk 'p!=$1{if(p)print s; s=$0; p=$1;...
If sorted:
awk 'p!=$1{if(p)print s; s=$0; p=$1; next}{s=s "," $2} END{print s}' file
5,335
Posted By Scrutinizer
If you only use TAB's for indent, you could use...
If you only use TAB's for indent, you could use <<- FTP instead of << FTP
3,632
Posted By radoulov
perl -e'BEGIN { %h = map { $_, ++$c } split...
perl -e'BEGIN {
%h = map { $_, ++$c } split //, shift
}
print sort { $h{substr $a, 0, 1} <=> $h{substr $b, 0, 1} } <>
' "dsap" infile
3,632
Posted By Scrutinizer
awk thingie: awk '{f=substr($1,1,1); A[f]=A[f]...
awk thingie:
awk '{f=substr($1,1,1); A[f]=A[f] $0 RS} END{ s=A["d"] A["s"] A["a"] A["p"]; print s}' ORS= file

--
Some awks can do this:
awk '{A[$1]=A[$1] $0 RS} END{ n=split(order,O); for(i=1;...
1,465
Posted By Jotne
Or some like this: awk ' { for(i=1;i <...
Or some like this:
awk ' {
for(i=1;i < NF;i++) {
if($i ~ /srv/) { split($i, s, "\"") }
if($i ~ /usr/) { split($i, u, "\"") }
if($i ~ /addr/) { split($i, a, "\"") }

} {print...
1,465
Posted By Scrutinizer
I don't know if is the most efficient script, but...
I don't know if is the most efficient script, but try:
awk -F\" '{for(i=1; i<=NF; i+=2) {sub(/.* /,x,$i); A[$i]=$(i+1)} print A["srv="], A["usr="], A["addr="]}' OFS=- file
-or-
awk -F\" 'function...
1,413
Posted By Scrutinizer
Hi, try: awk 'NR>1 &&...
Hi, try:
awk 'NR>1 && $3!~/^[yn]$/{sub(/./,"&|",$3)}1' FS=\| OFS=\| infile1
4,460
Posted By Scrutinizer
Awk only: awk '{p=$2; getline<f} !A[$2=p $2]++'...
Awk only:
awk '{p=$2; getline<f} !A[$2=p $2]++' f=file2 file1
awk '{getline $1<f; $0=$0} !A[$2]++' OFS= f=file1 file2
29,853
Posted By Scrutinizer
An awk version: awk 'NR>c{print A[NR%c]}...
An awk version:
awk 'NR>c{print A[NR%c]} {A[NR%c]=$0}' c=4 file
1,720
Posted By zaxxon
$ awk -F\| '{_[$3 FS $4 FS $2]++} END{for(e in...
$ awk -F\| '{_[$3 FS $4 FS $2]++} END{for(e in _){print "FREQ" FS e FS _[e]}}' infile
FREQ|A|V|3|2
FREQ|A|V|4|1
3,525
Posted By Corona688
If you have GNU awk: $ awk -v RS="ABC" '{...
If you have GNU awk:

$ awk -v RS="ABC" '{ $1="ABC " $1 } NF>1' data

ABC 123456 abcde 987 890456 7890 xyz ght gtuv
ABC 5tyin 1234 789 ghty kuio
ABC ghty jind 1234 678 ght

$
1,371
Posted By Scrutinizer
Date as a field separator in awk? Try: awk...
Date as a field separator in awk? Try:
awk -F'../../..' '{sub($1,x)}1' file
2,191
Posted By Corona688
I once wrote a generic XML scanner which produces...
I once wrote a generic XML scanner which produces output similar to what you want. It produces columns from tags in a generic way without hardcoding tags/attributes. It has a weakness in that it...
1,925
Posted By Scrutinizer
awk version: awk -F\*...
awk version:
awk -F\* '$1=="ST",$1=="SE"{if($1=="ST"){close(f);f="file" ++i} gsub(/~/,RS); $1=$1; print>f}' OFS=\| infile

--
On Solaris use /usr/xpg4/bin/awk rather than awk
1,107
Posted By Scrutinizer
Hi, try this: awk ' /^JOB_U/{ ...
Hi, try this:
awk '
/^JOB_U/{
split($1,F,/"/)
print F[4] OFS
}
/^Login/{
print $2
}
/^MSCRIPT/{
getline
gsub(/\n/,"; ")
print OFS $3
}
' RS=\< FS='[][>]*' ORS= infile
1,676
Posted By Scrutinizer
Try: awk -F= 'NR==FNR{split($1,F,/\./);...
Try:
awk -F= 'NR==FNR{split($1,F,/\./); A[$2]=F[2]; next} $2 in A{$3=$2; $2=A[$2]}1' file2 FS='[: \t]*' file1
2,419
Posted By Scrutinizer
Try: awk -F'[]]|CDATA[[]' '/<name>/{c=$2} c==n...
Try:
awk -F'[]]|CDATA[[]' '/<name>/{c=$2} c==n && /<byte>/{print $2}' n=xxapp2 infile
143,554
Posted By complex.invoke
Tetris Game -- The Art Of Shell Programming
GitHub - deepgrace/tetris: Tetris implementation in all kinds of Programming Languages (https://github.com/deepgrace/tetris)

Usage: bash Tetris_Game [ <runlevel> [ <previewlevel> [ <speedlevel> [...
17,279
Posted By Chubler_XL
To convert bytes to human readable value: ...
To convert bytes to human readable value:

awk ' BEGIN { split("bytes,KB,MB,GB,TB,PB,EB,ZB,YB",SZ,",") } { p=1;for(i=0;$1/p>1024;i++) p*=1024; printf "%4.4f %s\n", $1/p, SZ[i+1]}'
5,626
Posted By Chubler_XL
If your going to process a few images it is worth...
If your going to process a few images it is worth removing the calls to awk and using bash arrays/string processing instead.

Here is a version that defines font and size at to so you can trial...
2,107
Posted By Scrutinizer
@ctsgnb
OK, I'll have a go :):
awk -F: '{$1=$1;f=":%s\n%s\n";if($1!=p){if(p)printf f,s OFS (n""?n:x),r RS; s=$0;r=x;p=$1}
else r=r (r?RS:x)"\t: "$2" "$3;n+=$3}!(t=!t){s=s OFS n;n=x}
...
22,791
Posted By Scrutinizer
awk '{i=$1;sub(i,x);A[i]=A[i]$0}...
awk '{i=$1;sub(i,x);A[i]=A[i]$0} FILENAME==ARGV[ARGC-1]{print i A[i]}' file*
21,048
Posted By durden_tyler
You really should have a look at the "Special...
You really should have a look at the "Special Variables" section of the (FREE!!) online Perl documentation -

http://perldoc.perl.org/perlvar.html (http://perldoc.perl.org/perlvar.html)

Or...
9,092
Posted By Scrutinizer
Try: awk...
Try:
awk 'FNR==1{i=1}/head/{p=1;if(f)close(f);f=FILENAME"-part-"i++}p{print>f}/end/{p=0}' file*You can use extended regular expressions instead of head..
Showing results 1 to 25 of 37

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