Wednesday, May 30, 2007

[Work] sed examples

sed example:

an example file: img.h
#ifndef _GAN_IMAGE_RGBA_UINT_H
#define _GAN_IMAGE_RGBA_UINT_H
#include
#include

task: replace with "image_colour_noc.h"

done with:
sed -e 's//"\1"/g' img.h

sed example: bash

for i in *.c; do sed -e 's//"..\/common\/\1"/g' -e 's//"..\/linalg\/\1"/g' -e 's//"\1"/g' $i > sedtest/$i; done

sed example:
change:
obj: allocate.c bit_array.c compare.c gan_err.c list_test.c misc_error.c
array.c common_test.c endian_io.c gan_err_trace.c memory_stack.c numerics.c
array_noc.c comp_noc.c file_io.c linked_list.c misc_defs.c

to:
obj: allocate.c bit_array.c compare.c gan_err.c list_test.c misc_error.c
array.c common_test.c endian_io.c gan_err_trace.c memory_stack.c numerics.c
array_noc.c comp_noc.c file_io.c linked_list.c misc_defs.c

by:
sed 's/\.c *\([a-z]\)/\.c \1/g' Makefile

No comments: