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 09:12 PM
how to? launch command with string of command line options TinCanFury Shell Programming and Scripting 5 04-28-2008 07:06 PM
inconsistent ls command display at the command prompt & running as a cron job rajranibl SuSE 5 07-30-2007 09: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 05: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 10:44 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-25-2002
TRUEST TRUEST is offline
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
  #2 (permalink)  
Old 01-25-2002
santinojoe santinojoe is offline
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!
  #3 (permalink)  
Old 01-25-2002
jonas27 jonas27 is offline
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:57 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0