Skip to main content

Posts

Showing posts with the label command

10 Easy Examples of GNU sed Command Lines Episode 3

10 Easy Examples of GNU sed Command Lines Episode 3 Previously, we provided the first and second articles about GNU sed command line examples. Now it is the third article covering combination between sed and bash to do daily life jobs. We begin to focus in daily life jobs in this episode. This episode is a continuation of our previous articles. So if you miss something here, we suggest you to read the two previous episodes. Text Examples text6.txt: gnu gnu gnu gnu unix bsd bsd bsd bsd unix unix unix unix unix minix minix minix unix As previous articles go, save this file in your /tmp and perform all sed commands there.  21. Run Multiple Commands Command Example: sed -e s/gnu/U&/g -e s/bsd/U&/g text6.txt Output Example: master@master:/tmp$ sed -e s/gnu/U&/g -e s/bsd/U&/g text6.txt GNU GNU GNU GNU unix BSD BSD BSD BSD unix unix unix unix unix minix minix minix unix master@master:/tmp$ Explanation: We see the only different here compared to our previous e...

10 Easy Examples of GNU sed Command Lines

10 Easy Examples of GNU sed Command Lines GNU sed (stream editor) is a clone of UNIX sed command line program from GNU operating system. GNU sed is almost always included in every GNU/Linux distribution (e.g. Ubuntu). While the most of computer users edit a text file only with a real time text editor like Notepad, UNIX family users can edit a text file by a stream editor like sed. This article gives you the examples of stream editing for text file(s) with GNU sed. Because of it is GNU sed it is universal, so if you dont use Ubuntu (but at least you use any GNU/Linux distro), you can practice all of these command lines correctly. If you use another family of sed (e.g. UNIX or BSD one), probably you will need to adapt some commands because they have some differences. Checking sed Version Type this on your Terminal: sed --version Example Output: If you are using GNU/Linux, then your sed will produce this output indicating the origin of your sed (GNU operating system) and another important...