Printing out desired content

I want this script to read notes and print the contents of any file that starts with messages and is possibly followed by a period and a digit.

I've made this code, but how do I make it so that IF there is a period and a digit. Right now it only prints out the result if it is for example; notes.342 but won't give me plain notes.

Thxz for any help.



#!/usr/bin/perl 
 
@input = `cat notes`; 
 
foreach $line (@input){ 
    if($line =~ /notes\.[0-9]/){ 
	print $line; 
    } 
}

It's not clear what you want.

...read notes and print the contents of any file...
Is notes just one file?
Do you mean you want to print out any line?

...that starts with messages...
Your example starts with notes.

Are you sure you need a script? Would this work?

grep '^notes\.[0-9]' notes

What I basically want is a regular expression that always looks for notes and if there is a notes.934 for example, would also print it out.

Since my expression right now, only would print out notes.934 but would not print out notes plain.

Post your input file and the desired output between code tags.

Regards

Example.
Input:

notes.
ewrgrt53
notes gdasfert
fdgsdg
notes.34

Output:

notes.
notes gdasfert
notes.34

Try...

 
sed -n '/note/p' infile

What's wrong with an ordinary grep on 'notes'?

grep 'notes' file

Well I am practicing regular expressions. So I wanted to try this out^^ But it just doesn't work how I planned...

grep '^notes' file

searches for "notes" on the beginning of a line and should work with the given input file.

Regards