nixCraft Poll

Topics

Linux command editing examples using cat, ed, and sed

Posted by Vivek Gite [Last updated: January 16, 2007]

Linux and UNIX - Fast command line editing examples using cat, ed, and sed. Here is why you need to use command line editing tools...

#1: Text editor takes time for small editing
#2: Use command line editing
#3: Save time and impress your friends [ read as look like an elite UNIX hacker ;) ]

Take a quick look at some essential editing one-liners that can save you time and effort. Text-editing operations are normally done interactively, inside a text editor application. Some tasks, however, can be accomplished quickly and easily, right from the UNIX(R) command line. What's more, these one-liners can be used in scripts to automate various editing procedures.

This article demonstrates basic text-editing techniques with three of the most primary command-line editing tools readily available on all systems: cat, ed, and sed. The editing examples that follow start with the simplest and most common constructs and work up to the more complex.

You may also find this small shell script handy - to replaces all occurrence of javascript from HTML file :)

Read more at developerworks : Save time with text editing one-liners

Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.

You may also be interested in other helpful articles:

Discussion on This Article:

  1. Anil Alpati Says:

    I am facing problem while checking the text file in linux which is starting with minus sign

    Example:
    cat “-abc.txt”

    Please send me the reply at your earliest.

    Thanks,
    Anil.Alpati

  2. jose martin Says:

    Atleast one among the following should work
    cat ?abc.txt
    cat “-abc.txt”
    cat \-abc.txt

    Else you may rename that file to something normal by opening it in vi with command like:
    vi *abc.txt and when the required file opens in the vi, save it with a normal name.

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.