Text processing in Linux can be done using sed, cut, grep commands and with vi editor. We can find and replace a string, find and delete string etc.
Finding IP Addresses from Apache Log file through cut command
- The -d ‘-’ refers to delimeter –
- The -f1 is for first field in Apache log file
Remove particular IP Addresses from Apache log through sed command
- The -ie refers to inline edit in file
- The ‘/^10 indicates that IP must start with 10
- The \ indicates that special character . is text
- The /d indicates that delete this line
Remove lines containing a key word through sed
- The 1,30 refers to first 30 lines
- The {/index/d} indicates delete lines containing word “index”
Remove blank lines from a text file using vi editor
- The g refers globally
- The ^$/ d indicates delete blank lines
Remove special character # from a text file using vi editor
- The $s/ refers search from start
- The \# indicates take # as character
- The //g replace it with nothing i.e remove character










Comments
Leave a Reply