Hi, you could make a concoction with cut and grep but I don't think that would be very efficient. You can also do something with grep alone, but that would not be as accurate, e.g.:
grep 'john .* 20'
(if the field separator is a space)
Is there a specific reason why you can't use awk?
From the original post, I understand that he wants only the first field, although I'm not sure, so could be wrong. According with Scrutinizer, awk is one of the best tools for this job.
---------- Post updated at 11:20 AM ---------- Previous update was at 11:11 AM ----------
Hi Scrutinizer
actually i'm doing something with the values i'm getting i know awk is more flexible but in my project i have not used awk and i not good at awk so that's why from futher difficulties i don't use awk for the time being
anyways thanks for your help and time
and one last question can we use column number in the grep command? as we use it in cut -f1? just wondering what will be the structure
Hi, sed 's/ *\(.*\) \(.*\)/\2 \1/' flips the last field and any previous fields around...
Grep does not know fields, so you cannot use something like f1 in cut or $1 in awk...