The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help Required: Command to find IP address and command executed of a user loggedout Security 2 08-06-2008 05:12 PM
how to? launch command with string of command line options TinCanFury Shell Programming and Scripting 5 04-28-2008 03:06 PM
inconsistent ls command display at the command prompt & running as a cron job rajranibl Linux 5 07-30-2007 05:26 AM
How to use more than one MPE command STREAM with Unix command in a single shell? bosskr HP-UX 1 10-16-2006 01:16 PM
How to use more than one MPE command STREAM with Unix command in a single shell? bosskr Shell Programming and Scripting 0 09-19-2006 06:44 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 01-25-2002
Registered User
 

Join Date: Jan 2002
Posts: 144
What do you know about the Sed and Awk command??

I just need some information on what they can be use for and whatever else there is.

anything you know, state here
Forum Sponsor
  #2  
Old 01-25-2002
Registered User
 

Join Date: Jan 2002
Location: Quiddity
Posts: 1
why not do man sed or man awk
They should give you all the basics.

sed is a stream editor, lets you edit a file without actually going into the file in an editor like vi. Say you have a form letter and you need to change the greeting from "Dear Sir" to "Dear Madam". The command would be
sed 's/Dear Sir/Dear Madam/g' form-letter > new-form-letter
broken down
s = substitute
Dear Sir = the string you want to locate and replace
Dear Madam = the string you want to put in place of Dear Sir
g = global option = will change all instances of Dear Sir to Dear Madam
form-letter = the name of the file containing the stuff you want to change
new-form-letter = the name of the new file that will contain the changes

awk lets you locate particular records and fields in a database, and change them, display them, whatever.

day you have a data file of names and addresses, contacts:
01 Joe FirstSt
02 John SecondSt
03 Bill ThirdSt
04 Joe Fourthst

if you wanted to print only the records that contain the name Joe, you could
type
awk '/Joe/ {print $2}' contacts

/Joe/ = tells awk to find lines that contain the string Joe
{print $2} = tells awk to output the second field of the selected lines
contacts = the name of the data file you are searching

In both the sed and awk utilities, you need the apostrophes to pass the parameters to the utilities without the shell trying to interpret them.

check the man pages for more abilities and options
I'm a newbie too, so if I left something out, someone correct me!
__________________
moral indignation is jealousy with a halo.
  #3  
Old 01-25-2002
Registered User
 

Join Date: Sep 2001
Location: Canada
Posts: 12
Sed maybe right

from what I have learnt from the book I read Sed is something along these lines...I maybe wrong...from what I have read in here everyone I envy for there knowledge....Sed

e.g..

If you have a file like

don Migus 12 heart st california
and the file is called addresses

if you wanted to change the D's to j's you would write

sed '/d/j/' addresses....

I am not sure if this is correct as I dont have the book in front of me..and If I am wrong somebody please tell me and put in the write input....

But I am just trying
Google The UNIX and Linux Forums
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:38 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0