Hello, I have a file containing different words. How can i print the words which contain at least one small letter, for example if i have:
today TOMORROw 12345 123a
next preViou5 no
it should print the following:
today TOMORROw 123a
next preViou5 no
RudiC
2
Any attempts/ideas/thoughts from your side?
for word in $(<$f1); do
echo $word | grep "[a-z]"
done
$f1 stores the file name, the problem with my code is that the words are printed on separated lines.
RudiC
4
Please post your OS and shell next time.
On some OS, echo -n
suppresses <new line> chars. Or, use printf
if available in your system or shell.
This is a quick awk
solution:
awk '{for (i=1; i<=NF; i++) if ($i !~ /[a-z]/) $i = ""} 1' file3
today TOMORROw 123a
next preViou5 no
if you can tolerate the two spaces where a field has disappeared.
Thank you, problem solved!
hhdzhu
6
Hi, I think your code is cool but a little tricky,could you explain the meaning of this "$(<$f1)" especially the "<" here,thank you!