Overclockers Australia Forums
OCAU News - Wiki - QuickLinks - Pix - Sponsors  

Go Back   Overclockers Australia Forums > Software Topics > Other Operating Systems

Notices


Sign up for a free OCAU account and this ad will go away!
Search our forums with Google:
Closed Thread
 
Thread Tools
Old 7th August 2012, 2:41 PM   #1
ausghostdog Thread Starter
Member
 
Join Date: Feb 2010
Posts: 1,138
Default sed commands help

Working through my uni class and come to the following question

I know
-n = new line
s = substitute
q = quit
g= global
a= append

/ = delimiter

^ = start of a string
$ = end of a string
d = delete

Quote:
Assume you have a text file called file. Explain what does the following
command-line do.
1. sed "s/the/a/g" file
2. sed -n "s/[A-Z]/&/gp" file = substituting capital alphas and prints
3. sed "32,45 s/[()]//g" file = on line 32 and 45 replace or with nothing?
4. sed "/^$/d" file = remove empty lines from the file?
5. sed "s/\([0-9]\)-\([0-9]\)/\1\2/g" file = removes the - from number 1234-1234 to 12341234
6. sed "80q" file = display the first 80 lines and quit

I'm still working through the chapter in the book, any help understanding would be much loved.

Last edited by ausghostdog; 7th August 2012 at 3:07 PM.
ausghostdog is offline  

Join OCAU to remove this ad!
Old 7th August 2012, 2:55 PM   #2
GreenBeret
Member
 
GreenBeret's Avatar
 
Join Date: Dec 2001
Location: Melbourne
Posts: 16,892
Default

Create a text file and run the commands on it. Duh.
__________________
Doctore: Crixus! What is beneath your feet?
Crixus: Sacred ground, Doctore. Watered with tears and blood.
GreenBeret is offline  
Old 7th August 2012, 3:49 PM   #3
cleary
Mental in the Face
 
cleary's Avatar
 
Join Date: Apr 2003
Location: Griffith NSW
Posts: 3,876
Default

Help me with my homework is naughty - locked
__________________
SmugMug
cleary is online now  
Closed Thread

Bookmarks

Sign up for a free OCAU account and this ad will go away!

Thread Tools

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

Forum Jump


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


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. -
OCAU is not responsible for the content of individual messages posted by others.
Other content copyright Overclockers Australia.
OCAU is hosted by Internode!