Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Unix Script Help - SED

Thread Tools
 
Search this Thread
 
Old 25 April 2003, 08:39 AM
  #1  
marcmann
Scooby Regular
Thread Starter
 
marcmann's Avatar
 
Join Date: Oct 2002
Posts: 163
Likes: 0
Received 0 Likes on 0 Posts
Question

I'm having a hole in the head morning!

I've got a file containing various words, for example,

APPLE
BANANA
PEAR
MANGO

I'm using this command to print everything that starts with A but it isn't working.

cat file ¦sed '/^A*/p'

The result is that it just prints the whole file. I've tried it without using the * but the same thing happens? What am I missing??


Cheers

Marc
Old 25 April 2003, 10:00 AM
  #2  
ragnarock2
Scooby Regular
 
ragnarock2's Avatar
 
Join Date: Jan 2003
Posts: 502
Likes: 0
Received 0 Likes on 0 Posts
Post

Think you need a -n after the sed i.e. sed -n '/^A*/p'
the -n supresses output of lines that do not match
Old 25 April 2003, 10:15 AM
  #3  
Andrewza
Scooby Regular
 
Andrewza's Avatar
 
Join Date: Jan 2002
Posts: 667
Likes: 0
Received 0 Likes on 0 Posts
Post

Surely grep is the util for this

command | grep '^A.*'
Old 25 April 2003, 11:52 AM
  #4  
marcmann
Scooby Regular
Thread Starter
 
marcmann's Avatar
 
Join Date: Oct 2002
Posts: 163
Likes: 0
Received 0 Likes on 0 Posts
Thumbs up

Thankyou for your help - thats works a treat!

Marc
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
SD
Computer & Technology Related
6
24 April 2002 03:35 PM
SD
Computer & Technology Related
5
24 April 2002 10:29 AM
Karlos
Computer & Technology Related
9
10 March 2002 03:23 PM
Blackscooby
Computer & Technology Related
3
01 March 2002 09:25 AM



Quick Reply: Unix Script Help - SED



All times are GMT +1. The time now is 12:44 PM.