Search Results

Search: Posts Made By: yinyuemi
4,563
Posted By yinyuemi
Tha't weird, how about this?awk 'FNR==1{t++}{a[t"...
Tha't weird, how about this?awk 'FNR==1{t++}{a[t" "$1]=$2;b[$1]}END{for(i in b){printf i ;for(j=1;j<=t;j++)printf FS (length(a[j" "i])?a[j" "i]:"0");print ""}}'

or you can use "cat -A" to see if...
4,563
Posted By yinyuemi
I just test the code using your sample data, it...
I just test the code using your sample data, it works fine, my guess is the format of files make you fail, so please run dos2unix file1 file2 first, then re-run the awk code, see if it work.
4,563
Posted By yinyuemi
if you have multiple files,please try this:awk...
if you have multiple files,please try this:awk '{a[ARGIND" "$1]=$2;b[$1];t=ARGIND}END{for(i in b){printf i ;for(j=1;j<=t;j++)printf FS (length(a[j" "i])?a[j" "i]:"0");print ""}}' file1 file2 file1...
2,040
Posted By yinyuemi
awk...
awk 'NR==FNR{a[$0]=$0;next}{for(i=1;i<=NF;i++){t=m FS $i;m=$i;s(m,a);s(t,a)}}function s(x,b){if(x in b){print FILENAME,x,"=",$(i+1),$(i+2);i=i+2}}' searchstringfile.txt input*.txt
input1.txt J./F. =...
4,563
Posted By yinyuemi
awk '{if($1 in a){sub("0"...
awk '{if($1 in a){sub("0" FS,"",a[$1]);a[$1]=a[$1] FS $2}else{a[$1]="0" FS $2}}END{for(i in a)print i,a[i]}' file1 file2
1,317
Posted By yinyuemi
awk '{printf (/Written/)?$NF RS:$NF FS}'
awk '{printf (/Written/)?$NF RS:$NF FS}'
3,662
Posted By yinyuemi
grep -Po '(?<=PORT = )\d+'
grep -Po '(?<=PORT = )\d+'
840
Posted By yinyuemi
Probably "eval" could help you out, just show you...
Probably "eval" could help you out, just show you an example as below:

var="abc"
abc="###"
eval echo \${$var}
###

or you could also using "!" like
echo ${!var}
###
1,051
Posted By yinyuemi
awk '{$1=NR;$NF=NR%7?int(NR/7)+1:NR/7}1' file
awk '{$1=NR;$NF=NR%7?int(NR/7)+1:NR/7}1' file
3,451
Posted By yinyuemi
using the code as : {your first sed cod}...
using the code as :

{your first sed cod} files |{my sed code}>outfile
3,451
Posted By yinyuemi
sed -rn ' /Begin/!{ s/[^=]*= //; ...
sed -rn '
/Begin/!{
s/[^=]*= //;
s/[^:]*: //;
s/(.*) (.*)/\2,\1/;
H;
};
/Begin/{
s/[^:]*: //;
s/ .*//;
H;g;
s/\n//;
s/\n/","/g;
s/^/"/;
s/$/"/;
p;
...
1,216
Posted By yinyuemi
try:sed 's/="\([^"]*\)"/\1/g'
try:sed 's/="\([^"]*\)"/\1/g'
1,257
Posted By yinyuemi
echo 'entry1 entry2 entry3 entry4' |perl -alne...
echo 'entry1 entry2 entry3 entry4' |perl -alne 'print map {$_ x 2} map{$_." "} @F'
entry1 entry1 entry2 entry2 entry3 entry3 entry4 entry4
1,338
Posted By yinyuemi
gawk -F, '{ for(i=1;i<=NF;i++) ...
gawk -F, '{
for(i=1;i<=NF;i++)
{if(i==1||i==NF){a[NR,i]=$i;c[i]=i}
else{
if(NR!=4){a[NR,i]=$i}
...
10,972
Posted By yinyuemi
echo "a;s;v;g" | awk...
echo "a;s;v;g" | awk 'BEGIN{FS=OFS=";"}{$(NF--)=""; print}'
1,006
Posted By yinyuemi
dos2unix urfile, then try your code
dos2unix urfile, then try your code
2,951
Posted By yinyuemi
gawk 'NF==4{t=gensub(/[^ ]+(...
gawk 'NF==4{t=gensub(/[^ ]+( +).*/,"\\1",1,$0)}{gsub(t,"|");gsub(/ +/,"|")}1'
12,445
Posted By yinyuemi
echo 'dvgrab-2003.06.29_15-30-24.mpg' |\ while...
echo 'dvgrab-2003.06.29_15-30-24.mpg' |\
while read line
do
date_=`echo ${line#*-}|sed 's/_/ /;s/.mpg$//;s/-/:/g;s/\./-/g'`
echo "date: $date_"
echo "timestamp: "`date -d "$date_" "+%s"`
done...
2,411
Posted By yinyuemi
if condition then do something else do...
if condition
then
do something
else
do something
fi
2,207
Posted By yinyuemi
awk 'BEGIN{while("ls|grep -v total" |getline...
awk 'BEGIN{while("ls|grep -v total" |getline line){l=split(line,arr);a[++p]=arr[l]" was deployed on "arr[7]" "arr[6]" at"arr[8]" ET"}}
Hi mohtashims,
please remove the red "}", and try again, hope...
8,084
Posted By yinyuemi
echo '0 A 1 B 2 C - - - - - - N...
echo '0 A
1 B
2 C
- -
- -
- -
N XX
0 A1
1 B1
2 C1
- -
- -
- -
N XX1
0 A2
1 B2
2 C2
3 D3
- -
- -
2,207
Posted By yinyuemi
try using nawk or /usr/xpg4/bin/awk
try using nawk or /usr/xpg4/bin/awk
1,916
Posted By yinyuemi
awk 'NR==1{len=split($0,X);next} ...
awk 'NR==1{len=split($0,X);next}
{for(i=1;i<=NF;i++){
t=x=0
for(j=1;j<=len;j++){
x=sqrt((X[j]-$i)*(X[j]-$i)) # if the value of X[j]-$i could be negative or positive, this...
1,916
Posted By yinyuemi
I don't know if this codes can be run in csh, I...
I don't know if this codes can be run in csh, I did it in bash.

#!/bin/bash
XOFFS=(2 3 4 23 25 28 55 58) # array
BINDIST=(0 10 20 30 40 50 60) # array
echo ${XOFFS[@]} echo -e...
1,512
Posted By yinyuemi
perl -e '$str = "hello worlds lk lklolll"; ...
perl -e '$str = "hello worlds lk lklolll";
@a=split (/ /,$str);
foreach (@a){
@w=split(/x*/,$_);
++$q;
$p=0;
foreach (@w){
$o{$q}{++$p}=$_;
}
$n=$n>$p?$n:$p};
for($i=1;$i<=$n;$i++){...
Showing results 1 to 25 of 429

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