Thursday, October 4, 2007

using sed to edit a string in a file

action:
use sed to change a windows path 'g:\\' to a unix path '/share/data' in a file

command:
sed -e 's/g:/\/share\/data/g' -e 's/\\\\/\//g' file.2

comment:
sed == is a stream editor that can be used from the command line
format is - sed [command] <[inputfile]>[outputfile]
-e == is followed by a command, in this case a regex
< == is the input file
> == is the output file

No comments: