Search Results

Search: Posts Made By: xshang
2,139
Posted By xshang
I know a little more about awk again. Thanks!
I know a little more about awk again. Thanks!
2,139
Posted By xshang
It works, Thank you! ---------- Post updated...
It works, Thank you!

---------- Post updated at 02:38 AM ---------- Previous update was at 02:35 AM ----------



Nice! Thank you! Can you explain the code in awk? I never saw that kind of...
2,139
Posted By xshang
Sorry I can't express my desire clearly. What I...
Sorry I can't express my desire clearly. What I want is printing out the record when they have replicate $1.

---------- Post updated at 02:18 AM ---------- Previous update was at 02:18 AM...
2,139
Posted By xshang
Find the replicate record using awk
We usually use the following awk code to delete of find out the replicate record.

awk -F, '{a[$1]++} END {for (i in a) if (a[i]>=2) print i a[i]}' file

My question is how can I print the whole...
4,935
Posted By xshang
Nice, Thank you! ---------- Post updated at...
Nice, Thank you!

---------- Post updated at 02:01 PM ---------- Previous update was at 01:44 PM ----------



It works! vgersh99 gives a similar solution. Both of your codes runs faster.
...
4,935
Posted By xshang
Yes, I'm working on that. Thank you. I will make...
Yes, I'm working on that. Thank you. I will make a response later.
4,935
Posted By xshang
Thanks! Yes, this approach might not be...
Thanks!

Yes, this approach might not be efficiency. there are millions of strings in my file and hundreds of files to be searched. Do you have any other smart suggestions?

Thank you very much.
4,935
Posted By xshang
Grep multiple strings in multiple files
Hi, every one!

I have a file with multiple strings.
file1

ATQRGNE
ASQGVKFTE
ASSQYRDRGGLET
SPEQGARSDE
ASSRDFTDT
ASSYSGGYE
ASSYTRLWNTGE
ASQGHNTD
PSLGGGNQPQH
SLDRDSYNEQF


I want to...
1,128
Posted By xshang
How to get different record in two files?
Hello, guys!

I want to find difference between two file according $1. I using the following code, but get wrong results.

awk -F, 'NR==FNR{A[$1]=$0; next} $1!=A[$1]' file1 file2

I can using...
963
Posted By xshang
Thank you!
Thank you!
963
Posted By xshang
That's exact what I want. Thank you! ...
That's exact what I want.

Thank you!

---------- Post updated at 07:48 PM ---------- Previous update was at 07:30 PM ----------



Thank you very much!

How should I do if I want calculate...
963
Posted By xshang
how to using a variable in awk
Hello!

The following is my script:

#!/bin/bash

declare -a num
num=($(awk -F, '!_[$2]++{print $2}' HB291-0W-A4.txt | sort -k1.6n))

for f in HB291-0W-A4.txt
do
for...
1,632
Posted By xshang
#!/bin/bash declare -a num num=( 086 088...
#!/bin/bash

declare -a num
num=( 086 088 143 291 292)

for ((i=1;i<=4;i++))
do
for f in HB*
do
fname="HB${num[i]}*"
if [[ "$f" == "$fname" ]]; then
...
1,632
Posted By xshang
#!/bin/bash num[0]=021 num[1]=034 ...
#!/bin/bash

num[0]=021
num[1]=034
num[2]=056

for ((i=1;i<=5;i++))
do
for f in HB*
do
if [[$f == HB${num[i]*}]]; then
echo $f
else
...
1,632
Posted By xshang
how to use array variables in shell
Hi, everyone.

I wrote a code like this

for f in HB021*
do
program
done

for f in HB034*
do
program
done

for f in HB056*
do
program
done
.
.
3,844
Posted By xshang
It works! Thank you! I will study the code.
It works! Thank you! I will study the code.
3,844
Posted By xshang
Thank you!:b: The space is not a problem to me,...
Thank you!:b:
The space is not a problem to me, but I try to figure out which file the data come from.
3,844
Posted By xshang
---------- Post updated at 10:53 AM ----------...
---------- Post updated at 10:53 AM ---------- Previous update was at 10:42 AM ----------



Nice code! Thank you very much!

There is new problem in my file.
file1

AAAA 23 45...
3,844
Posted By xshang
How to combine two files with awk?
Hi, everyone!
I have two files, I want to combine them as follows:


File1
AAAA 23 45
AAAB 44 56
AAAC 34 65
AAAD 34 87

File2
AAAA 34 54
AAAE 34 56

Combined file
AAAA 23 45 34 54...
994
Posted By xshang
NICE code! Thank you!
NICE code! Thank you!
994
Posted By xshang
The file have sorted the highest value form the...
The file have sorted the highest value form the top, so it should be work.

When i run the code above, it shows the following information:

syntax error: operand expected (error token is "'awk...
994
Posted By xshang
sum and proportion calculation
I have a file like this:

ASSLRADTQY 319895
SAIVVGGSNQPQH 252661
ASSLDRGEIQPQH 237702
ASSYSPGGWTDTQY 106598
ASRMTGRATEAF 70363
SARDTRGEQY 69429
ASSLALDSEAF 58879
SATTWTSGLLDTQY 46100...
792
Posted By xshang
about loop in shell
Hi, morning, everyone!

I want to make more than one loop in a single shell script, this is what I want to do, but it doesn't run loop2.


#!/bin/bash
if f in *AA*
do
command1
...
1,115
Posted By xshang
Thank you. But it doesn't work, it should...
Thank you.

But it doesn't work, it should output have some record. How can I adjust and try?
1,115
Posted By xshang
merge two files according more than one field
I use the following code to merge two files according to $1;

awk -F, 'NR==FNR{A[$1]=$0; next} $1=A[$1]' file1 FS=, OFS=, file2

How should I change the code if I want to merge two files only...
Showing results 1 to 25 of 56

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