Search Results

Search: Posts Made By: delugeag
1,356
Posted By delugeag
awk '{ for (i=2;i<=NF;i++) { n[i,$i]++ ...
awk '{
for (i=2;i<=NF;i++) {
n[i,$i]++
}
}

END {
for (i=2;i<=NF;i++) {
print n[i,1] " " n[i,2]
}
}' file
1,611
Posted By delugeag
I don't understand. If you want to sort by...
I don't understand. If you want to sort by filename why do you use -rt option (sorted by reverse time) and not a simple :
ls -l

or if you want only size + filename :
find ./ -maxdepth 1 -printf...
1,217
Posted By delugeag
google : printf awk first result : Printf...
google : printf awk
first result : Printf Examples - The GNU Awk User's Guide (http://www.gnu.org/software/gawk/manual/html_node/Printf-Examples.html)

moreover a ">" delete the file and write the...
1,537
Posted By delugeag
Is this homeworks ?
Is this homeworks ?
2,111
Posted By delugeag
I think you can do it with awk ? the 1) ...
I think you can do it with awk ?
the 1)

awk '
/^.........patern/ {n+=1}
/^.....patern/ {m+=1}
end {print n ; print m}
' file 6 "." is for the patern in the 7th column.
2,275
Posted By delugeag
maybe it's the newline between `` Try with a \ ...
maybe it's the newline between `` Try with a \

DESC=`/bin/awk -F',' "/^$JOBNAME/" \
/apps/test/scripts/library/desc.output.$AUTO`
8,558
Posted By delugeag
You can use this sed: sed '/line 1 pattern/{...
You can use this sed:

sed '/line 1 pattern/{
N;
/\nline 2 pattern/ {
s/pattern/replace/
}
}' fileplease note when you use a "N" the pattern is in two line with \n separator. So you...
2,151
Posted By delugeag
cat $ORATAB | grep ^+ASM | wc -l please...
cat $ORATAB | grep ^+ASM | wc -l

please replace that by:
grep -c '^+ASM' $ORATAB
2,175
Posted By delugeag
$# return the number of argument.
$# return the number of argument.
1,157
Posted By delugeag
What is the line 23 ?
What is the line 23 ?
2,712
Posted By delugeag
You forgot to add the numbers of the even lines....
You forgot to add the numbers of the even lines. The code sould be :
sum[i]/2 ==> (sum[i] + $i)/2
5,285
Posted By delugeag
something like that ? awk ' $3 ~...
something like that ?

awk '
$3 ~ /^longest_sequence/ {
if (x[$2] == 0) { print }
x[$2]++
}
' file > output
6,617
Posted By delugeag
You can test it before asking if it could work!
You can test it before asking if it could work!
6,617
Posted By delugeag
arr[i] is the number of the i line. That mean if...
arr[i] is the number of the i line. That mean if "i=4" arr[i^2] will return the 16th lines and not the square of the 4th line.
1,089
Posted By delugeag
grep -w '"nathan available"'
grep -w '"nathan available"'
6,617
Posted By delugeag
for example : awk ' BEGIN {sum=0;summ=0} ...
for example :

awk '
BEGIN {sum=0;summ=0}
{
arr[NR]=$1
sum+=$1
}
END {
average=sum/NR

for (i=1;i<=NR;i++) {
summ+=(arr[i]-average)^2
}
print summ
}
' fileplease...
6,617
Posted By delugeag
If you want to read a file 2 times : awk ' ...
If you want to read a file 2 times :

awk '
FNR == NR {
first pass
next
}

{ second pass }
' file file
1,666
Posted By delugeag
Easy (but you have to add a condition if you want...
Easy (but you have to add a condition if you want to manage lines with only one field):
awk '{for (i=2;i<=NF;i++) {print $1 OFS $i}}' A.txt > B.txt
2,381
Posted By delugeag
The problem is wc -l give the line number and the...
The problem is wc -l give the line number and the filename. So 2 solutions :

test=$(wc -l $X | awk '{print $1}')

OR

test=$(cat $X | wc -l)sorry.
2,381
Posted By delugeag
awk '{ print $0 }' $X > “NR-${name}” "NR" is...
awk '{ print $0 }' $X > “NR-${name}”

"NR" is a awk variable, the bash can't guess it ! If you copy a file with the number of lines you must use wc -l :
NR=$(wc -l $X)
cp $X $NR-${name}
1,438
Posted By delugeag
file is the index (file2 in your example with "1...
file is the index (file2 in your example with "1 2 3 4 5 6 7").

awk '
function print_tab()
{
for (k=1;k<=j;k++) {
i=ind[k]
printf "%-4s",tab[i]
tab[i]="-"
}
printf "\n"...
1,396
Posted By delugeag
If files are sorted and they don't have headers...
If files are sorted and they don't have headers and the second field of file1 is never empty:
join -a 2 -e 'Not found in File1' -o 2.1,1.2 file1 file2
8734060356 2
8734079909 Not found in File1...
1,575
Posted By delugeag
And what is this line 55?
And what is this line 55?
1,365
Posted By delugeag
It's a pretty good idea but you have to learn...
It's a pretty good idea but you have to learn more about AWK:
echo 'a,b,c' | awk -F, '{$3 = "LTE" ; print $0 }'
=> a b LTESo if you wan to print only line with LTE in $3 there are a lot of...
1,575
Posted By delugeag
Oups, simple quote has been removed by the...
Oups, simple quote has been removed by the copy/paste.

awk '{printf "s/" $1 "/& (" ; for (i=2;i<=NF-1;i++) { printf $i " "};printf $NF")/g\n"}' drugs.txt > file_sed
Showing results 1 to 25 of 57

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