Web
Expertsforge
Home
FREE Signup
Login
Search
Advertise
Link to Us
Contact Us
Help
Login:
Home
» Categories |
Operating Systems
»
Linux Programming
» View Tutorial
Linux Programming Tutorial: Using SED to Edit strings in a File in Linux
jawahar
8/18/2005 2:03:41 AM, Views: 1395
string editor, sed, is used for editing lines in a file or a stream;
output is going to the standard output and can be re-directed to a
new file.
syntax:
sed [options] 'command1' [files]
sed [options] -e 'command1' [-e command2 ...] [files]
sed [options] -f script [files]
delete lines from 3 through 5 in file list.txt:
sed '3,5d' list.txt
delete lines that contain "o" at the beginning of the line:
sed '/^o/d' list.txt
translate capital c,r,o into small c,r,o:
sed 'y/cro/cro/' list.txt
delete ampty lines:
sed '/^$/d' list.txt
replace string oop with wee for the first occurence on a line
sed 's/oop/wee/' lsst.txt
remove ss string (replace with empty entry)for the first
occurence on a line:
sed 's/ss//' list.txt
remove ss string for all occurences on a line:
sed 's/ss//g' list.txt
substitute a single space for any number of spaces wherever
they occur on the line:
sed 's/ */ /g' list.txt
substitute underscore for any number of spaces wherever they
occur on the line:
sed 's/ */_/g' list.txt
Next Steps:
Add this Tutorial to:
Blink
Del.icio.us
Digg
Fark
Furl
Google
Reddit
Simpy
Spurl
Technorati
Win Live
Yahoo
Rate Me!
Not Yet Rated!
Rate:
Select Your Rating
Excellent!
Very Good
Good
Fair
Poor
Send Message
Signup
/
Login
To View the Solution or Provide Comments
Post Comment/Solution
Comment:*
(Link Rules)
Use :
[bold] for <b>; [/bold] for </b>; [italic] for <i>; [/italic] for </i>; [code] & [/code] for code
Categories
Applications
Operating Systems
Databases
Programming
Web Development
Networking
Security
Hardware
Search Engine Optimization
Make Money Online
Miscellaneous
Anti Spyware Software
Options
Submit a Tutorial
Ask a Question
Add to KB
Join as a Moderator?
Most Popular Tutorial
1.
Using SED to Edit st...
Most Popular Solution
No Records!
Top Rated
No Records!
Top Rankers
Overall
1. jawahar (50)
Yearly -2008
No Rankings!
Expertsforge Sponsors
1.
Tech News
2.
Wii Reviews
FREE Signup
Advertise
Link to Us
Contact Us
Sitemap
Tutorial Sitemap
About Us
Privacy Policy
Copyright 2004 - 2008 Expertsforge.com