Thanks, I know in this example I gave, egrep is a better choice, but actually my real work is "finding out both "user" and "nas" part, and then print out the result.
below is the result I want
+
user_a nas_b
user_d nas_b
user_a
user_c nas_m
+
But the problem is, no matter how i modified my script, I just won't get the desired result...
[QUOTE=radoulov;302286540]With
awk:
Code:
awk '{
for (i=1; i<=NF; i++)
if ($i ~ /user/)
print $i
}' infile