Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
If you notice col3 and 4 are contained within col1 and 2 (reading them by row).
I need to create a loop for this. First i need it to check if the quality is above a certain threshold (for example 30). If that is true, then I need the loop to determine if col3 is less than col2 but greater than col 1 and that col4 is less than or equal to col 2. How can I do this?
If you notice col3 and 4 are contained within col1 and 2 (reading them by row).
I need to create a loop for this. First i need it to check if the quality is above a certain threshold (for example 30). If that is true, then I need the loop to determine if col3 is less than col2 but greater than col 1 and that col4 is less than or equal to col 2. How can I do this?
I would strongly appreciate your help.
Hi,
how about
Code:
while read line;do
set -- $line
if [[ $(echo "$5 > 30 && $3>$1 && $3<$2 && $4<=$2" | bc) = 1 ]];then
echo $line
# or whatever you need to do
fi
done < file
[EDIT]
However, I just saw that you have floating point numbers. In this case an awk solution might be more appropriate:
If I wanted to take this a step further and replace the values in col2 with the values in col3 if they pass the awk criteria would I do something like this:
If I wanted to take this a step further and replace the values in col2 with the values in col3 if they pass the awk criteria would I do something like this:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.