8:47 PM SED command for filtering and transforming texts of a file using regular expression |
sed - stream editor for filtering and transforming text FORMAT DESCRIPTION Some useful parameters: -i[SUFFIX], --in-place[=SUFFIX] edit files in place (makes backup if suffix supplied). So if the input file is abc.txt, a backup file will be created as abc.txtSUFFIX add the contents of script-file to the commands to be executed. This file contains the regular exp and sunstitution word. used for SED Eg. Suppose we have file abc.txt like this: /home/user1:> cat abc.txt I want to find and replace "old" by "new". So I will use below command. somesed.sed is containing: :/home/user1:> cat somesed.sed So above command will use the somesed.sed file as script file and process the input file abc.txt and later will create a backup file as abc.txt.201404100831 . See the result: /home/user1:> sed -f somesed.sed -i.201404100831 abc.txt The backup file: |
|
Related blogs
You may also like to see:
[2014-09-13] | [Open System-Linux] |
md5sum: calculate and check md5 message digest of a file in Linux |
[2014-02-19] | [Open System-Linux] |
Shift Key is not working!! Mapping keyboard keys from one to another |
[2015-04-23] | [Open System-Linux] |
15 Great DATE command examples |
[2016-01-23] | [Open System-Linux] |
Some useful examples of netstat command in Linux for network statistics |
[2014-12-28] | [Open System-Linux] |
Shift command with examples |
Total comments: 0 | |