Eikonal Blog


sed tricks

Filed under: scripting, transformers — Tags: , , — sandokan65 @ 15:58

These one-liners are collected from various sites and articles on web – see the list of Sources at the bottom of this posting.

  • Deleting all empty lines from the input file:
    sed ‘/^$/d’ 
  • In-place replacement:
    sed –i ‘/^$/d’ INPUTFILE
  • In-place replacement with backup of original file:
    sed –ibak ‘/^$/d’ INPUTFILE
  • In-place deletion of all occurences of a string in a file:
    sed –i ‘/WORDTOBEDELETED/d’
  • How to replace the first occurrence only (of a string match) in a file, using sed
  • Append environment variable PATH with sed:
    sed -e '/^PATH/s/"$/:\/usr\/lib\/myprog\/bin"/g' -i /etc/environment
  • Remove all whitespace from beinning of lines:
    sed 's/^[ \t]*//g' foo
  • Deleting the / from all html files contained in current folder:
    sed -i ‘s/src=”\//src=”/g’ *.html
  • Greedy matching:
    % echo "foobar" | sed 's///g'
  • Non greedy matching:
    % echo "foobar" | sed 's/]*>//g'



Related here: Command line based text replace – https://eikonal.wordpress.com/2010/07/13/command-line-based-text-replace/.

Related here: Scripting languages – https://eikonal.wordpress.com/2010/06/15/awk-sed/ | Unix tricks – https://eikonal.wordpress.com/2011/02/15/unix-tricks/ | SED tricks – https://eikonal.wordpress.com/2010/10/05/sed-tricks/ | Memory of things disappearing > nmap stuff > getports.awk – https://eikonal.wordpress.com/2010/06/23/memory-of-things-disappearing-nmap-stuff-getports-awk/ | AWK – https://eikonal.wordpress.com/2011/09/30/awk/


Filed under: transformers — Tags: , , , , , — sandokan65 @ 14:49


Mail processing tools

CSV to/from LDIF

Finding difference of two MS Word documents

Port knocking

Filed under: firewalls, infosec, security hardening — Tags: — sandokan65 @ 14:20

More on this blog: IpTables – https://eikonal.wordpress.com/2011/01/24/iptables/ | Personal Computer Security > Personal Firewalls – https://eikonal.wordpress.com/2011/02/28/personal-computer-security/ | Firewalls – https://eikonal.wordpress.com/2012/05/04/firewalls/

Influencing the public opinion

This is an art old as society. A new twist on it:

Blog at WordPress.com.