Printing out desired content

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Printing out desired content
# 1  
Old 08-26-2009
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.

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

# 2  
Old 08-26-2009
It's not clear what you want. 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

# 3  
Old 08-26-2009
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.
# 4  
Old 08-26-2009
Post your input file and the desired output between code tags.

# 5  
Old 08-26-2009
notes gdasfert

notes gdasfert

# 6  
Old 08-26-2009

sed -n '/note/p' infile

# 7  
Old 08-26-2009
What's wrong with an ordinary grep on 'notes'?

grep 'notes' file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk pattern match not printing desired columns

Hi all, I'm trying to match the following two files with the code below: awk -F, 'NR==FNR {a=$0; next} ($12,$4) in a {print $12,$1,a}' OFS="," file4.csv file3.csv but the code does not print the entire row from file4 in addition to column 12 and 1 of file3. file4: o,c,q,co,ov,b... (1 Reply)
Discussion started by: bkane3
1 Replies

2. Shell Programming and Scripting

Facing issues with Content-Type:application/x-download Content-Disposition:attachment

I am in the process of developing a perl cgi page. I had succeeded in developing the page but there are few errors/issues with the page. description about cgi page: My CGI page retrieves all the file names from an directory and displays the files in drop down menu for downloading the... (5 Replies)
Discussion started by: scriptscript
5 Replies

3. UNIX for Dummies Questions & Answers

Help me in getting the desired result

Hi All, I have input file which is pipe delimited A | 1 B | 2 c | 3I need output of displaying total number of lines in a file as last column. A | 1 | 3-----total number of linesin file. B | 2 | 3 c | 3 | 3 (9 Replies)
Discussion started by: pravinashwin
9 Replies

4. Shell Programming and Scripting

need to get the desired output

Below is the my cide which is working fine but I am not getting the output indesired format.there is some problem in alignment.Can someone help me to correct this? if ]; then summary=$( echo -e "Please review the log file of auto coloclean utility.\n"; echo -e... (2 Replies)
Discussion started by: anuragpgtgerman
2 Replies

5. UNIX for Dummies Questions & Answers

Sco Unix printing : jobs hangs in queue - printing via lp versus hpnpf

Hi, We have a Unix 3.2v5.0.5. I installed a printer via scoadmin, HP network printer manager with network peripheral name (hostname and ipadres are in /etc/hosts). This is the configuration file : Code: root@sco1 # cat configurationBanner: on:AlwaysContent types: simpleDevice:... (0 Replies)
Discussion started by: haezeban
0 Replies

6. Windows & DOS: Issues & Discussions

Linux to Windows Printing: PDF starts printing from middle of page.

We are using Red Hat. We have a issue like this: We want to print from Linux, to a printer attached to a Windows machine. What we want to print is a PDF. It prints, but the printing starts from the middle of the page. In the report, there is no space at the top but still printing starts from the... (5 Replies)
Discussion started by: rohan69
5 Replies

7. Shell Programming and Scripting

printing the content from a file

hi , i m new to unix and i don no how to print this format i have output file like THE DOMAIN NAME VPORCL01 FOR THE HOSTNAME Ram-pc Port=1533 Port=9000 Listener Port=9100 THE DOMAIN NAME VPORCL02 FOR THE HOSTNAME Ram-pc Port=7000 Port=9000 Listener Port=9100 but i sholud print... (7 Replies)
Discussion started by: becksram123
7 Replies

8. HP-UX

Desired Format !

Hi everybody, I just need desired ouput from text file which should have folowing format; "2007-06-25 00:03:32.926+05:30",12354369,"Load","Completed","Rs.-5,556.00",9452217714 "2007-06-25 00:06:57.357+05:30",12354371,"Load","Completed","Rs.-56.00",9415766266 "2007-06-25... (1 Reply)
Discussion started by: prasanth_babu
1 Replies

9. Shell Programming and Scripting

Help me in getting the desired output

I wanted to put "|" this sign at starting and at end of every field but its not working with first field like Currently the out put is : abc | abc | abc | xyz | xyz | xyz | But I want the out put in this form: | abc | abc | abc | | xyz | xyz | xyz | plz help me. (2 Replies)
Discussion started by: akash
2 Replies

10. UNIX for Advanced & Expert Users

Printing Problems in unix ... ( Bar-cdoe - Ip Printing)

Hi guys ... i need ur help with some printing problem in unix ... first prob. : i wanna print from my NCR unix to an Win NT , Ip based printing server ( HP JetDirect ) . My issue , is it possible to print directly to an Ip address from unix ? How do i make it work to get any results ?... (3 Replies)
Discussion started by: QuickSilver
3 Replies
Login or Register to Ask a Question