Some sed examples

Removing comments and leading spaces

[pblair@fa003.dia pblair]$ cat test.txt
# this is a test file
echo on # this is an inline comment
  echo off


[pblair@fa003.dia pblair]$ cat test.txt  | sed s/#.*//g | sed s/'^\( \)*'//

echo on
echo off

Back to index