Find words containing small letters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find words containing small letters
# 1  
Old 04-10-2016
Find words containing small letters

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:

Code:
today TOMORROw 12345 123a
next preViou5 no

it should print the following:

Code:
today TOMORROw 123a
next preViou5 no

Moderator's Comments:
Mod Comment Please use code tags as required by forum rules!

Last edited by RudiC; 04-10-2016 at 02:16 PM.. Reason: Added code tags
# 2  
Old 04-10-2016
Any attempts/ideas/thoughts from your side?
# 3  
Old 04-10-2016
Code:
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.
# 4  
Old 04-10-2016
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:
Code:
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.
# 5  
Old 04-10-2016
Thank you, problem solved!
# 6  
Old 04-10-2016
Quote:
Originally Posted by JhonTheNewbie
Code:
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.
Hi, I think your code is cool but a little tricky,could you explain the meaning of this "$(<$f1)" especially the "<" here,thank you!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find & Replace with same case letters

I have text with upper and lower case words. I want to find something and replace it with something new. But it should match the case - Meaning - it should replace old upper cased word with NEW upper case word and lower with lower. example: this text is very simple TEXT. now I want to replace... (5 Replies)
Discussion started by: grep_me
5 Replies

2. Shell Programming and Scripting

Find and arrange words with same letters from list

I am making a word game and I am wondering how to find and arrange words in a list that have the same letters. In my game, you are presented with 5 letters, and you then have to rearrange the letters tp make a word. So the word could be "acorn", but those 5 letters could also make up "narco" or... (2 Replies)
Discussion started by: hellobard
2 Replies

3. Shell Programming and Scripting

AWK count letters words

Hi All! can anyone help me with this code? I want to count words or letters in every line with if(count>20){else echo $myline} awk '/<script /{p=1} /<\/script>/{p=0; next}!p' index.html | while read myline; do echo $myline done Thank you !!! (3 Replies)
Discussion started by: sanantonio7777
3 Replies

4. UNIX for Dummies Questions & Answers

Grep.Need help with finding the words which start at [A-K] letters in thesecond column of the table

Hi buddies ! I need some help with one grep command :) I have this table: 1 Petras Pavardenis 1980 5 08 Linas Bajoriunas 1970 10 3 Saulius Matikaitis 1982 2 5 Mindaugas Stulgis 1990... (1 Reply)
Discussion started by: vaidastf
1 Replies

5. Shell Programming and Scripting

Trying to find number of uppercase and lowercase letters.

Hello Guys, I am writing a script which check each line for how many Uppercase and Lowercase letter of a given file. Please check my script as follow: l=0 while read line do echo Line `expr $l + 1` has ` tr -cd "" < $line | wc -c` uppercase letters and `tr -cd "" < $line | wc -c`... (3 Replies)
Discussion started by: kasparov
3 Replies

6. Shell Programming and Scripting

ENQUIRY WHETHER SCRIPT FOR DETECTING WORDS FROM A SET OF LETTERS EXISTS

Hello, I am interested in finding out whether someone has a perl or awk script which takes a set of letters such as wak and referring to a dictionary spews out all possible forms such as awk, kaw etc. If someone has such a script, could it be put up please. The script should handle Unicode. Many... (0 Replies)
Discussion started by: gimley
0 Replies

7. Shell Programming and Scripting

Shell script to find out words, replace them and count words

hello, i 'd like your help about a bash script which: 1. finds inside the html file (it is attached with my post) the code number of the Latest Stable Kernel, 2.finds the link which leads to the download location of the Latest Stable Kernel version, (the right link should lead to the file... (3 Replies)
Discussion started by: alex83
3 Replies

8. Shell Programming and Scripting

extract words with even numbr of letters

Hello All I need to extract words which are of even number of letters and not greater than 10. Any help?? Thanks, Manish (3 Replies)
Discussion started by: manish205
3 Replies

9. Shell Programming and Scripting

change small letters to capital

hi guys, I know this might be very simple for u but not for me. I simply want to print the active users, changeing the first letter in their names to capital. i guess sed it's useful but don't know how to find the correspondign capital letter and don't know how to change just the first... (16 Replies)
Discussion started by: atticus
16 Replies

10. Shell Programming and Scripting

How can I find the 3 first letters from the name file

Hello, I have a name file in Unix for example : ABC_TODAYFirst.001 and I want just capture or display the 3 first letters so : ABC. I tried with cut -c,1-3 and the name but it displays the 3 first letters of all lines. Can you help , Thanks a lot (8 Replies)
Discussion started by: steiner
8 Replies
Login or Register to Ask a Question